如何在 UWP 中使用 XMLDocument.SelectNodes [英] How Can I Use XMLDocument.SelectNodes in UWP

查看:37
本文介绍了如何在 UWP 中使用 XMLDocument.SelectNodes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 UWP 应用程序编程的初学者,但我知道 C#.我的问题是,由于定义不存在,我如何在 UWP 应用程序中使用 selectnodes ......我将如何解决这个问题?谢谢.

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;

推荐答案

由于定义不存在,我如何在 UWP 应用程序中使用 selectnodes...我将如何解决此问题?

how could I use selectnodes in a UWP applications since the definition doesn't exist... How would i work around this issue?

问题是您为 XmlDocument 使用了错误的命名空间(System.Xml).请使用 Windows.Data.Xml.Dom 命名空间.有关更多信息,您可以参考 XmlDocument 类官方文档.

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;

这是官方 XML DOM 示例,请检查.

这篇关于如何在 UWP 中使用 XMLDocument.SelectNodes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆