【发布时间】:2011-10-20 04:33:50
【问题描述】:
我需要获取<name> 和<URL> 标签的值,其中subtype="mytype"。如何在PHP 中做到这一点?
我想要结果中的文档名称和 test.pdf 路径。
<?xml version="1.0" encoding="UTF-8"?>
<test>
<required>
<item type="binary">
<name>The name</name>
<url visibility="restricted">c:/temp/test/widget.exe</url>
</item>
<item type="document" subtype="mytype">
<name>document name</name>
<url visiblity="visible">c:/temp/test.pdf</url>
</item>
</required>
</test>
【问题讨论】:
-
php.net/manual/en/book.xml.php">XML Parser 扩展是一个选项吗?
-
我不确定是谁标记了你——或者为什么——但菲尔是绝对正确的。 SimpleXML(使用 XPath)是要走的路:w3schools.com/php/php_xml_simplexml.asp
-
@paulsm4:反对票来自我。原因是:没有显示研究成果,没有提供代码,并且可以通过 google 或 SO 搜索功能找到答案。
标签: php xml xml-parsing