CLEARALL(); XMLDoc := XMLDoc.XmlDocument; FileName := 'c:\temp\temp1.xml'; FileName := FileMgmt.UploadFileSilent(FileName); IF NOT EXISTS(FileName) THEN EXIT; f.OPEN(FileName); f.TEXTMODE(TRUE); f.CREATEINSTREAM(FileInStream); XMLDoc.Load(FileInStream); RootNode := XMLDoc.DocumentElement; MESSAGE(RootNode.Name + '-' + RootNode.InnerText); FindNode(RootNode, 'invoice', Node); IF NOT ISNULL(Node) THEN BEGIN MESSAGE(Node.Name + '-' + Node.InnerText); // this line is skipped if the xml file has xmlns, because the node cannot be found... END;
<content xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <invoice> <id>inv_001</id> <name>user name</name> </invoice> </content>
<content> <invoice> <id>inv_001</id> <name>user name</name> </invoice> </content>
Comments
You can find a lot information if you google for XML namespaces and SelectSingleNode and an example how to handle it in the MSDN: http://msdn.microsoft.com/de-de/library/system.xml.xmlnode.selectsinglenode(v=vs.110).aspx
The automation/dll itself is fully capable of handling namespaces and we do support it in Anveo EDI Connect.
http://www.sist.biz/en/ [en] | http://www.sist.biz [de]