How Can I Use XMLDocument.SelectNodes in UWP

安稳与你 提交于 2019-12-11 08:52:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!