如何在xml标签之间插入一个元素? [英] how to insert an element in between xml tag?
本文介绍了如何在xml标签之间插入一个元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<Exceptions>
<AllowedItems>
<Item Name="Jellyfish.jpg" Type="2" AddedDate="06/12/2013" User="XYZ" />
</AllowedItems>
</Exceptions>
在上面的xml格式中,我想实现这样的输出,
In above xml format, I want to achieve a output like these,
<Exceptions>
<AllowedItems>
<Item Type="2" AddedDate="06/12/2013" User="XYZ">"Jellyfish.jpg" </Item>
</AllowedItems>
</Exceptions>
推荐答案
查看这一个 [ ^ ]
不完全确定这是否是您要求的,但您可以通过InnerText属性在节点中添加文本:
Not entirely sure if this is what you're asking for, but you can add text in a node via the InnerText property:
XmlElement item = (XmlElement)doc.SelectSingleNode("//item");
item.InnerText = '"Jellyfish.jpg"';
如果这是你在找什么: http://msdn.microsoft.com/en -us / library / system.xml.xmlnode.innertext.aspx [ ^ ]
这篇关于如何在xml标签之间插入一个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文