【发布时间】:2011-02-03 06:23:42
【问题描述】:
我已经实现了在应用程序初始化时使用 XmlTextWriter 创建下面的 XML 文件。
并且知道我不知道如何使用 XmlDocument 和 XmlNode 更新 childNode id 值。
是否有一些属性可以更新 id 值?我试过 InnerText 但失败了。谢谢。
<?xml version="1.0" encoding="UTF-8"?>
<Equipment xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<License licenseId="" licensePath=""/>
<DataCollections>
<GroupAIDs>
<AID id="100">
<Variable id="200"/>
<Variable id="201"/>
</AID>
<AID id="">
<Variable id="205"/>
</AID>
<AID id="102"/>
</GroupAIDs>
<GroupBIDs>
<BID id="2000">
<AID id="100"/>
</BID>
<BID id="2001">
<AID id="101"/>
<AID id="102"/>
</BID>
</GroupBIDs>
<GroupCIDs>
<BID id="8"/>
<BID id="9"/>
<BID id="10"/>
</GroupCIDs>
</DataCollections>
</Equipment>
【问题讨论】:
-
Reading and Writing XML using c# 为什么不试试来这里问一个具体的问题呢?也向我们展示你到目前为止做了什么。
-
其实我也找了很多MSDN库的文章,做了一些练习,但是还是没有找到修改相关元素Attribute的方法。比如AID(element)的ID(attribute)和Variable(element)的ID(attribute)。我找不到 ChildNode 的 SetAttribute。谢谢。
-
挑剔:
应该有一个 结束标记 - 而不是 - 这不起作用,这不是有效的 XML 原样
标签: c# xml xmldocument xmlnode