<?xml version="1.0" encoding="utf-8"?>
goed bedrijf Solutions99
Akkabi n
Hertenrade 113
2544 he
Den haag
Info@noa-it.com
Eenmanszaak
2578723
Nl145155663B02
verplicht
verplicht
Nl41ingb0006618174
kontant
nee
ja
Info@noa-it.com
Nawil
Akkabi
Nak@noa-it.com
0624420920
Eigenaar
Ja
Ja
Ja
Ja
Ja
Ja
Ja
// The import function in NAV cant handle with the xmlns line in the xml file. So a work around is to strip the line with the
//xmlns in it.
dFile.TEXTMODE(FALSE);
dFile.OPEN(Filename);
dFile.CREATEINSTREAM(Stream);
InputText.READ(Stream);
dFile.CLOSE;
duplicateChambreofCommerce.SETRANGE(“Chamber of Commerce no.”,duplicateChambreofCommerce.“Chamber of Commerce no.”);
IF duplicateChambreofCommerce.FINDFIRST THEN
ERROR(‘nummer bestaat al’);
IF ISSERVICETIER THEN BEGIN
IF UPLOADINTOSTREAM(
‘Select the simple.xml file’,
‘\svdh04\data\NAV docs\webaanmelding’,
‘XML File *.xml| *.xml’,
Filename,
Stream) THEN
MESSAGE(ImportCompleteText)
ELSE
EXIT;
END
ELSE BEGIN
dFile.OPEN(Filename);
dFile.CREATEINSTREAM(Stream);
IF NOT XMLPORT.IMPORT(50010,Stream) THEN MESSAGE(ErrorText)
ELSE MESSAGE(ImportCompleteText);
END;
Hi Niels,
Than you will have to continue searching for a long time. That value is not in your file.
But exactly what is it that you’re trying to do? Is it related to your other question?
As a general rule, then I never import directly into NAV using XMLPorts. At least not when it’s tables that are just a little complex. I always uses my own little Import Development Pattern.
Import file into an Import Queue table in a BLOB field.
XMLPort reads data into “import buffer file” (temporary)
Verify import buffer - validation - record errors in file - sets status in import queue to error or verified (or skipped)
Reads the verified buffer file to the record.
The advantage of this “pattern” is to ensure that we always can say why a file was not imported, and if required just verify and read it again. It’s something I build quite some years ago, and has continued to “enhance”. But a lot less than what I had could do it. Remember that the “temporary” buffer file is not required to be included in the customers license, as you never inserts the data into the table.
I actually wrote my last reply Xhavat, but forgot to press post!
To read a value from an XML file you first you need to pass it to the file to an outstream and then to the XMLDocument.
Here you then load the node list (which I think you don’t need, as you have no nodes your that file). After you have fetched the node list (if it exists), then you can read the actual XML node.
IF ISCLEAR(XMLDoc) THEN
CREATE(XMLDoc);
XMLDoc.load(oStream);
IF NodeListExists(XMLDoc,Node,'/') THEN
LoadNodeListAndNode(XMLDoc,NodeList,Node,'/')
ELSE
ERROR('No child nodes');
IF GetNodeText(Node,'<Kvk>') = '6777' THEN;
PROCEDURE LoadNodeListAndNode@1000000002(VAR XMLDocument@1100006000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{88D96A05-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v6.0'.DOMDocument60";VAR XMLNodeList@1100006002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF82-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNodeList";VAR XMLNode@1100006001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode";ElementName@1000000000 : Text[250]);
VAR
NodeLength@1000000004 : Integer;
BEGIN
XMLNodeList := XMLDocument.selectNodes(ElementName);
NodeLength := XMLNodeList.length;
XMLNode := XMLNodeList.item(0);
END;
PROCEDURE NodeListExists@1000000009(VAR XMLDocument@1100006003 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{88D96A05-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v6.0'.DOMDocument60";VAR XMLNode@1100006000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode";ElementName@1000000000 : Text[250]) : Boolean;
BEGIN
XMLNode := XMLDocument.selectSingleNode(ElementName);
IF NOT ISCLEAR(XMLNode) THEN
EXIT(XMLNode.hasChildNodes)
ELSE
EXIT(FALSE);
END;
LOCAL PROCEDURE GetNodeText@1000000031(VAR Element@1100006002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{88D96A05-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v6.0'.DOMDocument60";NodeName@1000000002 : Text[50]) : Text[1024];
VAR
Node@1100006001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode";
DebugTxt@1000000004 : Text[1023];
BEGIN
Node := Element.selectSingleNode(NodeName);
IF ISCLEAR(Node) THEN
EXIT('');
EXIT(Node.text);
END;