在PHP中解析Microsoft XML

问题描述

我有一个XML文件(Word文档的一部分),它是非常简单的XML:

<?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
                        )
                )
        )
)

我想念什么?

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)