我无法理解为什么这个NodeList是空的
XmlDocument document = new XmlDocument();
document.Load(xmlpath);
XmlNodeList nodes = document.SelectNodes("/StructureResponse/rootItem/attributes/Attribute");
Run Code Online (Sandbox Code Playgroud)
这里是XmlFile
<?xml version="1.0" encoding="utf-8"?>
<StructureResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://nts-de-osm1-pxc/webservices/">
<consolidatedItems xsi:nil="true" xmlns="http://systinet.com/wsdl/com/osm/webservices/service/" />
<rootItem xsi:type="Part" xmlns="http://systinet.com/wsdl/com/osm/webservices/service/">
<attributes>
<Attribute>
<dataDictionary xsi:nil="true" />
<dataType>string</dataType>
<displayName>IDENT_NR</displayName>
<key>true</key><name>IDENT_NR</name>
<searchable>true</searchable>
<userAttribute>true</userAttribute>
<value>9662744</value>
</Attribute>
<Attribute>
<dataDictionary xsi:nil="true" />
<dataType>string</dataType>
<displayName>AI</displayName>
<key>true</key><name>AI</name>
<searchable>true</searchable>
<userAttribute>true</userAttribute>
<value>00</value>
</Attribute>
</rootItem>
</StructureResponse>
Run Code Online (Sandbox Code Playgroud)
在最终脚本中,我想获得一个包含其中每个属性的数组字符串.
谢谢Stefan
嗨,这里有我的xml文件:(文件)
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://nts-de-osm1-pxc/webservices/">
<Item xmlns:q1="http://systinet.com/wsdl/com/osm/webservices/service/" xsi:type="q1:Document">
<q1:attributes>
<q1:Attribute>
<q1:dataDictionary xsi:nil="true" />
<q1:dataType>string</q1:dataType>
<q1:displayName>AEND_DATUM</q1:displayName>
<q1:key>false</q1:key>
<q1:name>AEND_DATUM</q1:name>
<q1:searchable>true</q1:searchable>
<q1:userAttribute>true</q1:userAttribute>
<q1:value>10.05.10</q1:value>
</q1:Attribute>
<q1:Attribute>
<q1:dataDictionary xsi:nil="true" />
<q1:dataType>string</q1:dataType>
<q1:displayName>AEND_PRUEF_DATUM</q1:displayName>
<q1:key>false</q1:key>
<q1:name>AEND_PRUEF_DATUM</q1:name>
<q1:searchable>true</q1:searchable>
<q1:userAttribute>true</q1:userAttribute>
<q1:value>10.05.10</q1:value>
</q1:Attribute>
</q1:attributes>
</Item>
</ArrayOfItem>
Run Code Online (Sandbox Code Playgroud)
这是我的代码
$xml = simplexml_load_file($thefile);
print_r($xml);
Run Code Online (Sandbox Code Playgroud)
这是输出
SimpleXMLElement Object
(
[Item] => SimpleXMLElement Object
(
)
)
Run Code Online (Sandbox Code Playgroud)
为什么这是空的?