本文介绍了从PHP中的嵌套xml(具有:标记名称)中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的xml
<item> <title>test title</title> <link>www.test</link> <pubDate>Sun, 27 Aug 2017 06:22:29 +0000</pubDate> <post-id xmlns="com-wordpress:feed-additions:1">1111</post-id> <ev:tribe_event_meta xmlns:ev="Event"> <ev:startdate>November 13, 2017</ev:startdate> <ev:enddate>November 14, 2017</ev:enddate> <ev:venue>venue</ev:venue> <ev:address>address</ev:address> <ev:city>city</ev:city> <ev:zip></ev:zip> </ev:tribe_event_meta> </item>通过此xml,我就能获得 title ,链接等...
Form this xml i am able to get title, link etc...
但是我无法在内获取任何数据ev:tribe_event_meta 。我需要获取 ev:startdate , ev:enddate 等的值。
But im not able to get any data inside ev:tribe_event_meta. I need to get the value of ev:startdate, ev:enddate,etc.
请帮忙。
预先感谢。
注意: 我正在使用 Drupal Feed Import 。
推荐答案XML只是一个文本文件。如果您的解析器无法像这样解析,请尝试在将文件内容传递给解析器之前对文件进行搜索/替换。即将每个 ev:startdate替换为 ev_startdate或其他内容。
XML is just a text file. If your parser can't parse it like that try just doing search/replace on file before passing the file content to the parser. I.e. replace every "ev:startdate" with "ev_startdate" or something.
更多推荐
从PHP中的嵌套xml(具有:标记名称)中获取值
发布评论