问题
I am a beginner in programming UWP applications, but I know c#. My question is, how could I use selectnodes in a UWP applications since the definition doesn't exist... How would i work around this issue? Thanks.
Here is my code if needed
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:
how could I use selectnodes in a UWP applications since the definition doesn't exist... How would i work around this issue?
The problem is that you have used wrong namespace(System.Xml) for XmlDocument. Please use Windows.Data.Xml.Dom namespace. For more you could refer to XmlDocument class official documentation.
using Windows.Data.Xml.Dom;
......
XmlDocument responseXML = new XmlDocument();
responseXML.LoadXml(response);
string innerText = responseXML.SelectNodes("//maininfo").Item(0).InnerText;
Here is official XML DOM sample, please check.
来源:https://stackoverflow.com/questions/45681575/how-can-i-use-xmldocument-selectnodes-in-uwp