【发布时间】:2020-09-20 04:14:23
【问题描述】:
我有一个非常简单的 XML 文件(Word 文档的一部分):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="Matter"><vt:lpwstr>30738</vt:lpwstr></property><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="Document number"><vt:lpwstr>999999</vt:lpwstr></property></Properties>
但是,当我使用 SimpleXML 解析它时,我获得了 <property> 项的所有属性,但无法访问这些值(例如,<vt:lpwstr>999999</vt:lpwstr>)。
$custom = simplexml_load_string($xml);
print_r($custom);
// Results in:
SimpleXMLElement Object
(
[property] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[fmtid] => {D5CDD505-2E9C-101B-9397-08002B2CF9AE}
[pid] => 2
[name] => Matter
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[fmtid] => {D5CDD505-2E9C-101B-9397-08002B2CF9AE}
[pid] => 3
[name] => Document number
)
)
)
)
我错过了什么?
谢谢!
【问题讨论】: