So, to read this sample XML, that contain 4 namespaces:
<?xml version="1.0" encoding="utf-8"?> <ns1:Structure xmlns:ns1="http://www.influe.com/xns/2000/xmlfile/deffile/definition"
xmlns:gr="http://www.influe.com/xns/2000/xmlfile/deffile/groupe"
xmlns:li="http://www.influe.com/xns/2000/xmlfile/deffile/line"
xmlns:zn="http://www.influe.com/xns/2000/xmlfile/deffile/zone"> <gr:MESSAGE> <li:TESTATA> <zn:TIPO_RECORD_EN>EN</zn:TIPO_RECORD_EN> <zn:MITTENTE_MESSAGGIO>4324234</zn:MITTENTE_MESSAGGIO> </li:TESTATA> <gr:group1> <li:GERARCHIA> <zn:NUMERO_DESADV_HE>DDT1</zn:NUMERO_DESADV_HE> </li:GERARCHIA> </gr:group1> <gr:group1> <li:GERARCHIA> <zn:NUMERO_DESADV_HE>DDT2</zn:NUMERO_DESADV_HE> </li:GERARCHIA> </gr:group1> <gr:group1> <li:GERARCHIA> <zn:NUMERO_DESADV_HE>DDT3</zn:NUMERO_DESADV_HE> </li:GERARCHIA> </gr:group1> </gr:MESSAGE> </ns1:Structure>
You can proceed like that:
static void Job92(Args _args) { XmlDocument xmlDoc = XmlDocument::newFile(@"YOURPATH\file.xml"); XmlNamespaceManager nmgr = new XmlNamespaceManager(new XmlNameTable()); XmlNode node; XmlNodeList nodeList; ; nmgr.addNamespace("ns1", "http://www.influe.com/xns/2000/xmlfile/deffile/definition"); nmgr.addNamespace("li", "http://www.influe.com/xns/2000/xmlfile/deffile/line"); nmgr.addNamespace("gr", "http://www.influe.com/xns/2000/xmlfile/deffile/groupe"); nmgr.addNamespace("zn", "http://www.influe.com/xns/2000/xmlfile/deffile/zone"); // nodo TESTATA node = xmldoc.selectSingleNode("//li:TESTATA", nmgr); infO(node.xml()); // lista group1 nodeList = xmldoc.selectNodes("//gr:group1"); while(true) { node = nodeList.nextNode(); if(node == null) break; // esempio lettura elemento all"interno di group1 node = node.selectSingleNode("li:GERARCHIA/zn:NUMERO_DESADV_HE", nmgr); info(node.text()); } }