2017-08-14 65 views
0

我是編程UWP應用程序的初學者,但我知道c#。我的問題是,如何在UWP應用程序中使用selectnodes,因爲該定義不存在......我將如何解決此問題?謝謝。如何在UWP中使用XMLDocument.SelectNode

這裏是我的代碼,如果需要

XmlDocument responseXML = new XmlDocument(); 
responseXML.LoadXml(response); 

string innerText = responseXML.SelectNodes("//maininfo").Item(0).InnerText; 
responseXML.LoadXml(innerText); 

info1 = responseXML.GetElementsByTagName("upnp:info1").Item(0).InnerText; 
info2 = responseXML.GetElementsByTagName("upnp:info2").Item(0).InnerText; 
info3 = responseXML.GetElementsByTagName("dc:info3").Item(0).InnerText; 
info4 = responseXML.GetElementsByTagName("dc:info4").Item(0).InnerText; 
+1

indentation was off ..使問題更具可讀性 – sa77

回答

0

我怎麼會在UWP應用,因爲該定義不存在使用的selectNodes ...我將如何解決這個問題?

問題是您使用了錯誤的名稱空間(System.Xml)作爲XmlDocument。請使用Windows.Data.Xml.Dom命名空間。欲瞭解更多,你可以參考XmlDocument類官方文檔。

using Windows.Data.Xml.Dom; 

...... 

XmlDocument responseXML = new XmlDocument(); 
responseXML.LoadXml(response); 
string innerText = responseXML.SelectNodes("//maininfo").Item(0).InnerText; 

這裏是official XML DOM sample,請檢查。