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.得到的元素它解決了這個問題。 –