Answers for "selectnodes query is not working"

C#
0

selectnodes query is not working

XmlDocument doc = new XmlDocument();
doc.LoadXml(SqlScriptXml);
 
XmlNodeList nodeList;
 
if (doc.DocumentElement.Attributes["xmlns"] != null)
{
    string xmlns = doc.DocumentElement.Attributes["xmlns"].Value;
    XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
 
    nsmgr.AddNamespace("MsBuild", xmlns);
 
    nodeList = doc.SelectNodes("/MsBuild:Project/MsBuild:ItemGroup/*", nsmgr);
}
else
{
    nodeList = doc.SelectNodes("/Project/ItemGroup/*");
}
 
foreach (XmlNode node in nodeList)
{
    string name = node.Name;
}
Posted by: Guest on January-26-2021

Code answers related to "selectnodes query is not working"

C# Answers by Framework

Browse Popular Code Answers by Language