【发布时间】:2012-09-01 02:46:23
【问题描述】:
我有以下从 Web 服务调用收到的 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命名空间有问题?
【问题讨论】:
标签: .net xml xml-parsing linq-to-xml