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?

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

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题