我有像这样的 test.xml 的 xml 文件:
<?xml version="1.0" encoding="utf-8" ?>
<Message>
<Item Name ="msg1" Status ="false"/>
<Item Name="msg2" Status="false"/>
</Message>
System.Xml.XmlTextReader textReader = new System.Xml.XmlTextReader(test.xml);
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.Load(test.xml);
var testreader = xdoc.DocumentElement.ChildNodes;
string name = string.Empty;
string value = string.Empty;
if (message.MsgType == 10005)
{
value = "true";
}
else if (message.MsgType == 10002)
{
value = "false";
}
foreach (var mychild in testreader)
{
var childatt = ((System.Xml.XmlElement)mychild);
name = childatt.Attributes["Name"].Value;
value = childatt.Attributes["Status"].Value;
}
我必须做的事情是:
- 我必须使用 xmltestReader 和 xmldocument 在 xml 文件中保存更新的值
- 我从第三个客户端收到关于 messageID 的请求,所以我必须检查它是否存在于 xml 文件中(例如,获取 msg1 的请求,所以我必须匹配它是否存在的 xml 文件)。
希望我的问题很清楚。