在下面的代码中,我需要获取根节点内的节点值
Root Node : <basemap:AlterationService xmlns:basemap="http://www.xxx.com/basemap">
为此,我需要向 XmlNodeList 提供节点名称,以便获取数据。我正在使用下面的 c# 代码来获取值,但是,我得到了错误,
'<basemap:AlterationService xmlns:basemap="http://www.xxx.com/basemap"' has an invalid token.
C# :
XmlDocument xml = new XmlDocument();
xml.Load("C:/Test/Sample.xml");
string RootNode = "basemap:AlterationService xmlns:basemap=\"http://www.xxx.com/basemap\"";
XmlNodeList xnList = xml.SelectNodes(RootNode); //Error in this line
foreach (XmlNode xn in xnList)
{
................
................
}
XML :
<?xml version="1.0"?>
<basemap:AlterationService xmlns:basemap="http://www.xxx.com/basemap">
.....
.....
</basemap:AlterationService>