Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PHP选择XML属性_Php_Xml - Fatal编程技术网

如何使用PHP选择XML属性

如何使用PHP选择XML属性,php,xml,Php,Xml,我有一个XML,我想在其中选择一个特定的属性。 XML中的一个条目如下所示: <show time="27652"> <user cn="User5" guid="abc" e164="15" h323="User5" text="100000" loc="Everywhere" node="root" filter="normal" cd-filter="normal" reporting="true" uclic="true" type="ep"> <

我有一个XML,我想在其中选择一个特定的属性。 XML中的一个条目如下所示:

<show time="27652">
  <user cn="User5" guid="abc" e164="15" h323="User5" text="100000" loc="Everywhere" node="root" filter="normal" cd-filter="normal" reporting="true" uclic="true" type="ep">
    <presence c="tel:" s="closed" a="vacation"/>
    <device hw="user-5"/>
    <grp name="TAPI"/>
    <grp name="soap"/>
  </user>
</show>
这不起作用,它没有显示任何内容。虽然我把它改成了文本=100000

我还打印变量$show以查看是否有错误。更改前:

SimpleXMLElement Object (
    [user] => SimpleXMLElement Object (
            [@attributes] => Array (
                    [cn] => User5
                )
        )
)
修改后:

SimpleXMLElement Object (
    [user] => SimpleXMLElement Object (
            [@attributes] => Array (
                    [text] => 100000
                )
        )
)
我觉得这个也不错。那么,我的错误在哪里

$showresult为空,$master是连接详细信息。。。 多谢各位

SimpleXMLElement Object (
    [user] => SimpleXMLElement Object (
            [@attributes] => Array (
                    [cn] => User5
                )
        )
)
SimpleXMLElement Object (
    [user] => SimpleXMLElement Object (
            [@attributes] => Array (
                    [text] => 100000
                )
        )
)