我有一个 xml 文件,我想反转一些节点,然后我想保存结果。我使用了 XDocumnt 并在其上使用了 revese 函数,它正确地反转了,但之后我不知道如何保存文件。像下面这样的原始文件
<root>
<parent>
<child>
<sec>
<p>
<my-formula>
<test id="H1"></test id="H1">
</my-formula>
<my-formula>
<test id="H2"></test id="H2">
</my-formula>
<my-formula>
<test id="H3"></test id="H3">
</my-formula>
</p>
</sec>
<sec>
<p>
<my-formula>
<test id="H4"></test id="H4">
</my-formula>
<my-formula>
<test id="H5"></test id="H5">
</my-formula>
<my-formula>
<test id="H6"></test id="H6">
</my-formula>
</p>
</sec>
</child>
</parent>
</root>
我需要将其反转如下:
<root>
<parent>
<child>
<sec>
<p>
<my-formula>
<test id="H6"></test id="H6">
</my-formula>
<my-formula>
<test id="H5"></test id="H5">
</my-formula>
<my-formula>
<test id="H4"></test id="H4">
</my-formula>
</p>
</sec>
<sec>
<p>
<my-formula>
<test id="H3"></test id="H3">
</my-formula>
<my-formula>
<test id="H2"></test id="H2">
</my-formula>
<my-formula>
<test id="H1"></test id="H1">
</my-formula>
</p>
</sec>
</child>
</parent>
</root>
之后,我想将其保存到新文件中。
谁能帮我?