I have been trying to parse an XML file with C# without success. I need to use the SelectSingleNode and SelectNodes methods to get, for example, the information for the path /cfdi:Comprobante/cfdi:Conceptos/cfdi:Concepto/cfdi:Impuestos/cfdi:Traslados. The situation I am facing is the namespace, I have not found a way to deal with it.
I have done several thing like the code below, "playing" with the nsmgr namespace variable and the path for the nodes variable without success.
XmlDocument doc = new XmlDocument();
doc.Load("c:/725.xml");
XmlElement root = GetRoot();
var nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("ex", "cfdi");
var nodes = root.SelectNodes("/Comprobante/Conceptos/Concepto/Impuestos/traslados", nsmgr);
return View();
I attach the XML file for your reference.
725.xml
Bestr regards.