• <bdo id='ovwyu'></bdo><ul id='ovwyu'></ul>

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

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

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

        C# 将根添加到 XDocument

        时间:2023-08-26

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

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

                  <tbody id='LHuII'></tbody>

                • <legend id='LHuII'><style id='LHuII'><dir id='LHuII'><q id='LHuII'></q></dir></style></legend>

                  <tfoot id='LHuII'></tfoot>

                • 本文介绍了C# 将根添加到 XDocument的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个包含 XML 的字符串,可以这样说:

                  I have a string that contains an XML, lets say like this:

                  <Novels> 
                   <Book>
                    <Title>Cat in hat</Title>
                    <Price>12</Price>
                   </Book>
                  </Novels>
                  

                  我想制作一个如下所示的 XDocument:

                  I want to make an XDocument that looks like this:

                  <Booklist>
                   <Novels> 
                    <Book>
                     <Title>Cat in hat</Title>
                     <Price>12</Price>
                    </Book>
                   </Novels>
                  </Booklist>
                  

                  我可以使用 XDocument doc = XDocument.Parse(xmlString);

                  如何在新的根目录下加载文档.我可以考虑使用我想要的根创建一个新的 XDocument,然后使用 for 循环将节点添加为子节点,但是有更简单的方法吗?

                  How would I load the document under a new root. I can think of something like creating a new XDocument with the root I want and then using a for loop to add the nodes as children, but is there an easier way of doing this?

                  推荐答案

                  XDocument yourResult = new XDocument(new XElement("Booklist", doc.Root));
                  

                  这篇关于C# 将根添加到 XDocument的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:编写xml并读回c# 下一篇:将硒与电子框架联系起来(c#)

                  相关文章

                  最新文章

                    • <bdo id='dxVmk'></bdo><ul id='dxVmk'></ul>
                  1. <i id='dxVmk'><tr id='dxVmk'><dt id='dxVmk'><q id='dxVmk'><span id='dxVmk'><b id='dxVmk'><form id='dxVmk'><ins id='dxVmk'></ins><ul id='dxVmk'></ul><sub id='dxVmk'></sub></form><legend id='dxVmk'></legend><bdo id='dxVmk'><pre id='dxVmk'><center id='dxVmk'></center></pre></bdo></b><th id='dxVmk'></th></span></q></dt></tr></i><div id='dxVmk'><tfoot id='dxVmk'></tfoot><dl id='dxVmk'><fieldset id='dxVmk'></fieldset></dl></div>
                    <tfoot id='dxVmk'></tfoot>

                    <legend id='dxVmk'><style id='dxVmk'><dir id='dxVmk'><q id='dxVmk'></q></dir></style></legend>
                    1. <small id='dxVmk'></small><noframes id='dxVmk'>