有没有办法使用 Linq 将 XML 中的所有现有值替换为字典中的值?我正在使用 c#。
XML 示例:
<root>
<node1> <--without attribute
<subNode1>someTextValue</subNode1>
</node1>
<node2 name="myNode2"> <--With attribute (IMPORTANT!!!)
<subNod1>someOtherTextValue</subNode1>
</node2>
</root>
Dictionary<string, Hashtable> dataFromXML;
dataFromXML Keys
从这个例子是node1 (because here is note an attribute), myNode2 (because here is an attribute)
......
dataFromXML Values
是子节点。
现在假设我们在某个子节点中进行了一些值更改,并且我们想要更新 XML。
我怎么能这样做而不是用foreach循环???
希望我的问题得到明确定义。
编辑
XElement 和 ReplaceWith 函数呢?
最好的问候。