douzhi7451 2014-10-16 10:59
浏览 20
已采纳

XML数据获取帮助需要[重复]

This question already has an answer here:

I have a XML file for my project work.I need to fetch the data from the XML file.The file contains something like the following:

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:szgd="http://www.spotzot.com/gdfeed" xmlns:szbb="http://www.spotzot.com/bbfeed">
<channel>
<item>
<title>Service &amp; Maintenance under $50</title>
<description>7 Items | Prestone, Campbell Hausfeld, Custom Accessories, Custom, KD Tools</description>
<szgd:instore>Y</szgd:instore>
</item>
</channel>
</rss>

I am using $newtitle=$newxml->channel->item->title; to fetch data from title.It successfully returned the title.

How can I fetch the data from tag in my page using php?

</div>
  • 写回答

1条回答 默认 最新

  • dongzi5673 2014-10-16 12:52
    关注

    Use php's simplexml functions.

    Load it with: $xml = simplexml_load_string($xml); if you are having a string or $xml = simplexml_load_file($xmlFile); if you are having a file.

    if the xml was valid you will get a SimpleXmlElement. Check the following link: http://php.net/manual/en/class.simplexmlelement.php. There you will find several functions on how to get data out of it.

    Btw. which data you really want to get?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line