如何根据id读取en和cn
<?xml version= "1.0 " encoding= "utf-8 " ?>
<strings>
<string ID= "1 " EN= "Add " CN= "填加 " />
<string ID= "2 " EN= "Update " CN= "修改 " />
<string ID= "3 " EN= "Delete " CN= "删除 " />
<string ID= "4 " EN= "Search " CN= "查询 " />
</strings>
------解决方案--------------------------------------------------------
XmlNodeList lists = doc.GetElementsByTagName( "string ");
foreach (XmlNode list in lists)
list.Attributes[0].Value;
list.Attributes[2].Value;
------解决方案--------------------------------------------------------
http://blog.csdn.net/cgy220/archive/2007/02/05/1502429.aspx
实在不行用正则
------解决方案--------------------------------------------------------
高老師說得不錯,像這樣:
XmlDocument xml = new XmlDocument();
xml.Load( "a.xml ");
XmlNodeList lists = xml.GetElementsByTagName( "string ");
foreach (XmlNode list in lists)
{
if(list.Attributes[0].Value== "2 ")
{
textBox1.Text = list.Attributes[2].Value;
}
}
------解决方案--------------------------------------------------------
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load( "test.xml ");
XmlNodeList nodeLists =xmldoc.SelectSingleNode( "string ")
foreach (XmlNode list in nodeLists)
{
textBox1.Text = list.Attributes[2].Value.ToString().Trim();
}
都說了﹐頂﹐接分﹗