如何在XML文件中添加额外的行 [英] How to add an extra line in XML file

查看:118
本文介绍了如何在XML文件中添加额外的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vs 2010 vb.net,我能够创建一个xml文件,就像下面的例子一样,如果你能看到我们有四行并且光标位于最后一行的末尾。现在我得到的是在最后一个标签注释之后有另一行(空行)并且光标出现在它上面,即第5行。只需要检查行数。我必须使用ultra edit打开xml文件,超编辑显示xlm以及行号。



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



- 空格在这里,下一行/ note--



我的尝试:



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

- 常规xml在这里结束,光标在/ note的同一行 -

解决方案

从您的问题看来,您似乎将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[^]


这篇关于如何在XML文件中添加额外的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆