1
我从Web服务调用接收到以下一段XML。Linq to XML,无法获取节点值
<Wireless xmlns="http://www.hikvision.com/ver10/XMLSchema">
<enabled>true</enabled>
<ssid>Network 1</ssid>
<WirelessSecurity>
<securityMode>WPA-personal</securityMode>
</WirelessSecurity>
<WPA>
<algorithmType>TKIP</algorithmType>
<sharedKey>asdfasdf</sharedKey>
<wpaKeyLength>13</wpaKeyLength>
</WPA>
<WEP>
<authenticationType>auto</authenticationType>
<defaultTransmitKeyIndex>224</defaultTransmitKeyIndex>
<EncryptionKeyList>
<encryptionKey>AScii</encryptionKey>
</EncryptionKeyList>
</WEP>
</Wireless>
我想通过它并填充一个对象,但我没有执行最基本的操作。我已经在名为document
的XDocument中成功解析了它。当我写下声明
var elem = document.Element("Wireless");// returns null
var elem = document.Element("ssid");// also returns null
var elem = document.Descendants("ssid");//produces empty enumeration
我在做什么错在这里?由于不同的xml命名空间,是否有问题?
感谢L.B.得到的元素它解决了这个问题。 –