久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <legend id='OIa8H'><style id='OIa8H'><dir id='OIa8H'><q id='OIa8H'></q></dir></style></legend>

    <small id='OIa8H'></small><noframes id='OIa8H'>

        <i id='OIa8H'><tr id='OIa8H'><dt id='OIa8H'><q id='OIa8H'><span id='OIa8H'><b id='OIa8H'><form id='OIa8H'><ins id='OIa8H'></ins><ul id='OIa8H'></ul><sub id='OIa8H'></sub></form><legend id='OIa8H'></legend><bdo id='OIa8H'><pre id='OIa8H'><center id='OIa8H'></center></pre></bdo></b><th id='OIa8H'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OIa8H'><tfoot id='OIa8H'></tfoot><dl id='OIa8H'><fieldset id='OIa8H'></fieldset></dl></div>

      1. <tfoot id='OIa8H'></tfoot>

          <bdo id='OIa8H'></bdo><ul id='OIa8H'></ul>

        讀取 XML(從字符串)并獲取一些字段 - 讀取 XML 時出

        Read a XML (from a string) and get some fields - Problems reading XML(讀取 XML(從字符串)并獲取一些字段 - 讀取 XML 時出現問題)

            <tfoot id='tLdJz'></tfoot>

              <tbody id='tLdJz'></tbody>
            <legend id='tLdJz'><style id='tLdJz'><dir id='tLdJz'><q id='tLdJz'></q></dir></style></legend>

              <bdo id='tLdJz'></bdo><ul id='tLdJz'></ul>
            • <small id='tLdJz'></small><noframes id='tLdJz'>

              • <i id='tLdJz'><tr id='tLdJz'><dt id='tLdJz'><q id='tLdJz'><span id='tLdJz'><b id='tLdJz'><form id='tLdJz'><ins id='tLdJz'></ins><ul id='tLdJz'></ul><sub id='tLdJz'></sub></form><legend id='tLdJz'></legend><bdo id='tLdJz'><pre id='tLdJz'><center id='tLdJz'></center></pre></bdo></b><th id='tLdJz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tLdJz'><tfoot id='tLdJz'></tfoot><dl id='tLdJz'><fieldset id='tLdJz'></fieldset></dl></div>
                  本文介紹了讀取 XML(從字符串)并獲取一些字段 - 讀取 XML 時出現問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有這個 XML(存儲在一個名為 myXML 的 C# 字符串中)

                  I have this XML (stored in a C# string called myXML)

                  <?xml version="1.0" encoding="utf-16"?>
                  <myDataz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                    <listS>
                      <sog>
                        <field1>123</field1>
                        <field2>a</field2>
                        <field3>b</field3>
                      </sog>
                      <sog>
                        <field1>456</field1>
                        <field2>c</field2>
                        <field3>d</field3>
                      </sog>
                    </listS>
                  </myDataz>
                  

                  我想瀏覽所有 <sog> 元素.對于他們每個人,我想打印孩子 <field1>.

                  and I'd like to browse all <sog> elements. For each of them, I'd like to print the child <field1>.

                  這是我的代碼:

                  XmlDocument xmlDoc = new XmlDocument();
                  string myXML = "<?xml version="1.0" encoding="utf-16"?><myDataz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><listS><sog><field1>123</field1><field2>a</field2><field3>b</field3></sog><sog><field1>456</field1><field2>c</field2><field3>d</field3></sog></listS></myDataz>"
                  xmlDoc.Load(myXML);
                  XmlNodeList parentNode = xmlDoc.GetElementsByTagName("listS");
                  foreach (XmlNode childrenNode in parentNode)
                  {
                      HttpContext.Current.Response.Write(childrenNode.SelectSingleNode("http://field1").Value);
                  }
                  

                  但似乎我無法將字符串讀取為 XML?我得到 System.ArgumentException

                  but seems I can't read a string as XML? I get System.ArgumentException

                  推薦答案

                  你應該使用 LoadXml 方法,而不是 Load:

                  You should use LoadXml method, not Load:

                  xmlDoc.LoadXml(myXML); 
                  

                  Load 方法試圖從文件中加載 xml 并從字符串中加載 LoadXml.你也可以使用 XPath:

                  Load method is trying to load xml from a file and LoadXml from a string. You could also use XPath:

                  XmlDocument xmlDoc = new XmlDocument();
                  xmlDoc.LoadXml(xml);
                  
                  string xpath = "myDataz/listS/sog";
                  var nodes = xmlDoc.SelectNodes(xpath);
                  
                  foreach (XmlNode childrenNode in nodes)
                  {
                      HttpContext.Current.Response.Write(childrenNode.SelectSingleNode("http://field1").Value);
                  } 
                  

                  這篇關于讀取 XML(從字符串)并獲取一些字段 - 讀取 XML 時出現問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標簽的 XML)
                  Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                  delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                  Parse malformed XML(解析格式錯誤的 XML)
                1. <legend id='szGm5'><style id='szGm5'><dir id='szGm5'><q id='szGm5'></q></dir></style></legend>

                      <i id='szGm5'><tr id='szGm5'><dt id='szGm5'><q id='szGm5'><span id='szGm5'><b id='szGm5'><form id='szGm5'><ins id='szGm5'></ins><ul id='szGm5'></ul><sub id='szGm5'></sub></form><legend id='szGm5'></legend><bdo id='szGm5'><pre id='szGm5'><center id='szGm5'></center></pre></bdo></b><th id='szGm5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='szGm5'><tfoot id='szGm5'></tfoot><dl id='szGm5'><fieldset id='szGm5'></fieldset></dl></div>
                        <bdo id='szGm5'></bdo><ul id='szGm5'></ul>

                        <tfoot id='szGm5'></tfoot>

                        <small id='szGm5'></small><noframes id='szGm5'>

                            <tbody id='szGm5'></tbody>
                            主站蜘蛛池模板: 久久精品国产99国产 | 在线观看免费av网 | 国产高清在线 | 亚洲视频在线观看一区二区三区 | a级免费黄色片 | 国产99视频精品免费播放照片 | 最新国产在线 | 精品国产乱码久久久久久影片 | 一区二区三区在线看 | 色婷婷久久 | 69av网 | 久久久不卡网国产精品一区 | 日韩欧美国产一区二区三区 | 日本在线视频中文字幕 | 国产区免费视频 | 欧美不卡在线 | 欧美激情国产日韩精品一区18 | 亚洲欧美国产精品一区二区 | 国产一级在线观看 | 99热.com | 欧美一区2区三区3区公司 | 久久人爽爽人爽爽 | 欧美一区二区三区视频 | 狠狠躁夜夜躁人人爽天天高潮 | 日韩在线视频一区 | 国产综合久久 | 亚洲天堂一区 | 国产精品不卡视频 | 一区二区免费 | 日韩av免费在线电影 | 日本高清在线一区 | 亚州国产 | 自拍偷拍视频网 | 一区二区三区四区在线 | 国产福利在线看 | 亚洲精品视频免费观看 | 欧美一区视频 | 国产在线激情视频 | 日日摸夜夜爽人人添av | www.欧美 | 精品一区二区三区在线观看 |