又来提问了!关于XML
想问下大家,我想用一个XML文件作为配置文件。不知道如何读取到指定节点的值,请各位指教。
<?xml version= "1.0 " encoding= "UTF-8 "?>
<person>
<name> ME </name>
<title> UFO </title>
</person>
请给个范例
------解决方案--------------------try
{
string svla1 = string.Empty;
string svla2 = string.Empty;
XmlDocument mXml = new XmlDocument();
mXml.Load(this._FilePath);
XmlNode xnode = mXml.SelectSingleNode( "//person ");
foreach (XmlNode xno in xnode.ChildNodes)
{
if (xno.Name == "name ")
{
svla1 = xno.InnerXml;
}
else if ( xno.Name == "title ")
{
svla2 = xno.InnerXml;
}
}
}
catch (Exception ex)
{
throw ex;
}