从PHP中的嵌套xml(具有:标记名称)中获取值

编程入门 行业动态 更新时间:2024-10-23 23:32:55
本文介绍了从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(具有:标记名称)中获取值

本文发布于:2023-11-12 12:40:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581516.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌套   标记   名称   PHP   xml

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!