繁体   English   中英

无法在Windows Phone通用应用中解析xml

[英]Unable to parse xml in windows Phone universal app

我下面有要解析的XML,但我无法解析。 我已经检查了所有可以检查的可能性。

    <?xml version="1.0" encoding="utf-8"?>

<toast>

  <visual>

    <binding template="ToastText01">

      <text id="1">Test message</text>

      <text id="section">TRS</text>

    </binding>

  </visual>

</toast>

我试图解析根元素,但收到空值

 string  xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <toast > <visual> <binding template = \"ToastText01\" ><text id = \"1\" > Test message </text > <text id = \"section\"> tias-request-show </text> </binding ></visual> </toast> ";

    XDocument xdoc = XDocument.Parse(xml);
            XElement value = xdoc.Root.Element("toast");

尝试

 XElement value = xdoc.Element("toast");

无需访问Root即可获取toast -node。

我想通了

xdoc.Document.Element(“ toast”);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM