简体   繁体   中英

Unable to parse xml in windows Phone universal app

I have below XML which i want to parse but i am not able to parse. i have checked all possibilities which i can check.

    <?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>

I tried to parse root elemeny but receiving null value

 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");

Try

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

There is no need to access Root to get hold of the toast -node.

I figured out

xdoc.Document.Element("toast");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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