复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<subtitles>
<info>
<content>最新通告:五一放假七天!请各教员悉知</content>
<speed>4</speed>
<color>red</color>
</info>
</subtitles>
复制代码 代码如下:
XmlDocument xml = new XmlDocument();
xml.Load(context.Server.MapPath("~/js/XMLFile.xml"));
XmlNode xn = xml.DocumentElement;
foreach (XmlNode node in xn.ChildNodes)
{
if (node.Name == "info")
{
node["content"].InnerText = content;
node["speed"].InnerText = speed;
node["color"].InnerText = color;
}
}
xml.Save(context.Server.MapPath("~/js/XMLFile.xml"));
复制代码 代码如下:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<fsdlconfig userName=/"ss/" password=/"134/"/>");
XmlAttribute att =(XmlAttribute)doc.SelectSingleNode("/fsdlconfig/@userName");
Console.WriteLine(att.Value);
att.Value = "test";
string str = doc.OuterXml;
复制代码 代码如下:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<fsdlconfig userName=/"ss/" password=/"134/"/>");
XmlElement att = (XmlElement)doc.FirstChild;
att.SetAttribute("userName","test");
string str = doc.OuterXml;
新闻热点
疑难解答
图片精选