我的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<layout name="layout">
<section name="Header">
<placeholder name="headers" width="30" class="header">sam,pam</placeholder>
</section>
<section name="Content">
<placeholder name="RightA" width="55">location</placeholder>
</section>
</layout>
如果它包含,我想替换整个节点sam
。如果节点包含sam
我想重写节点意味着:
<placeholder name="headers" width="4,5,91">sam,sam2,pam</placeholder>
代替:
<placeholder name="headers" width="30" class="header">sam,pam</placeholder>
在 C# 中:
XmlDocument doc = new XmlDocument();
string sFileName = @"FileNameWithPath";
doc.Load(sFileName );
foreach (XmlNode ....... )
{
//Need help hear how to loop and replace.
}
谢谢。