如何对一xml格式的字符串分析? c#
http://topic.csdn.net/t/20021102/16/1142056.html
use classes in System.Xml namespace, for example (assume your xml is in string s and it contains an xmlns definition):
<ns:vi id="New_main" xmlns:ns="whatever">
<ns:node Expandable="checkOnce" Selected="true" ID="a1">
root<ns:node ID="a2">
Node1
</ns:node>
</ns:node>
</ns:vi>
string s = "................";
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(s);
XmlNamespaceManager xnm = new XmlNamespaceManager(xmldoc.NameTable);
xnm.AddNamespace("ns","whatever");
XmlNode node = xmldoc.SelectSingleNode("//ns:node[@ID='a1']", xnm);
if (node != null)
{
XmlAttribute att = xmldoc.CreateAttribute("bbi");
att.Value = "xxxxxxxxxxx";
node.Attributes.Append(att);
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/carl2380/archive/2010/01/17/5203421.aspx