且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在XML文件中添加额外的行

更新时间:2023-11-25 15:07:34

从您的问题看来,您似乎将XML文件与简单的文本文件相关联......虽然文件存储中表示的最终XML确实可以给人的印象是它完全是关于文本的,但实际上XML由节点...父节点和子节点组成......

因此,对于XML,您不添加LINE,但您可以添加节点(当然还有属性)...

您选择父节点并添加一个新子节点...



有关如何在.NET中处理XML(VB或其他)的详细信息,请参阅这里:

XML文档和数据 [ ^

i am using vs 2010 vb.net, i was able to create an xml file just like the example below, if you can see we have four rows there and the cursor is at the end of the last line. now what i have to get is to have another line (empty line) after the the last tag note and the cursor appear on it, that be the 5th row.just to check the number of rows row . i must open the xml file using ultra edit, ultra edit show the xlm along with the row number.

<note>
 <to>Tove</to>
 <from>Jani</from>
 </note>


--space in here, next line after /note--

What I have tried:

<note>
<to>Tove</to>
<from>Jani</from>
</note>

--regular xml ends in here, the cursor is in the same line of /note--

From your question it seems you are relating ti a XML file like a simple text file...While it is true that the final XML represented in a file-storage can give the impression that it is all about text, in truth XML is made of nodes...parent and child nodes...
So to XML you do not add a LINE, but you may add a node (and attributes of course)...
You pick the parent node and add a new child...

For details how to handle XML in .NET (VB or others) read here:
XML Documents and Data[^]