Multiple XML-file import

Christian_Wandborg
Member Posts: 23
Hi,
Using the 'XML Import Sample v1.0i' as is from the Download section, I have no problems. I would like the sample to import multiple xml-files simultaneously though, but faced with the error message (attached image), I'm stuck.
Now, as mentioned, the sample are working just fine as is with minor adjustments to accommodate the file structure.
If the existing code on the OnRun trigger is inactivated and/or replaced with:
XMLFile.INIT;
XMLFile.RESET;
XMLFile.SETRANGE(Path, 'C:\TEMP\TEST\ARCHIVE\');
XMLFile.SETRANGE("Is a file", TRUE);
IF XMLFile.FINDFIRST THEN BEGIN
REPEAT
FileName := XMLFile.Name;
OpenXMLDocument(FileName,XMLDocument);
ImportXMLFile(FileName);
UNTIL XMLFile.NEXT = 0;
END ELSE BEGIN
MESSAGE('No files to import');
END;
The errormessage is triggered.
These are the Locals on OnRun:
Name DataType Subtype
XMLDocument Automation 'Microsoft XML, version 2.0'.DOMDocument
XMLFile Record File
My xml-structure is as follows:
<ORDER>
<HEADING>
<DEPT>200</DEPT>
<NO>5000</NO>
</HEADING>
</ORDER>
If you have any suggestions, please don't hesitate
Using the 'XML Import Sample v1.0i' as is from the Download section, I have no problems. I would like the sample to import multiple xml-files simultaneously though, but faced with the error message (attached image), I'm stuck.
Now, as mentioned, the sample are working just fine as is with minor adjustments to accommodate the file structure.
If the existing code on the OnRun trigger is inactivated and/or replaced with:
XMLFile.INIT;
XMLFile.RESET;
XMLFile.SETRANGE(Path, 'C:\TEMP\TEST\ARCHIVE\');
XMLFile.SETRANGE("Is a file", TRUE);
IF XMLFile.FINDFIRST THEN BEGIN
REPEAT
FileName := XMLFile.Name;
OpenXMLDocument(FileName,XMLDocument);
ImportXMLFile(FileName);
UNTIL XMLFile.NEXT = 0;
END ELSE BEGIN
MESSAGE('No files to import');
END;
The errormessage is triggered.
These are the Locals on OnRun:
Name DataType Subtype
XMLDocument Automation 'Microsoft XML, version 2.0'.DOMDocument
XMLFile Record File
My xml-structure is as follows:
<ORDER>
<HEADING>
<DEPT>200</DEPT>
<NO>5000</NO>
</HEADING>
</ORDER>
If you have any suggestions, please don't hesitate

Regards
Christian
Christian
0
Answers
-
What code do you have in function OpenXMLDocument?
Have you created the XMLDOM like
CREATE(XmlDoc);0 -
Hi
Use the create statement to initialize the automation variable xmlDocument.
Hope this helps
Thomas0 -
Hi,
This is the code (Emiel Romein) http://www.mibuso.com/dlinfo.asp?FileID=329Documentation() OnRun() { "XML File Name" := 'C:\TEMP\TEST\ARCHIVE\TEST_1.xml'; // File name parameter. ImportXMLFile("XML File Name"); // Import XML File } XMLFile.INIT; XMLFile.RESET; XMLFile.SETRANGE(Path, 'C:\TEMP\TEST\ARCHIVE\'); XMLFile.SETRANGE("Is a file", TRUE); IF XMLFile.FINDFIRST THEN BEGIN REPEAT FileName := XMLFile.Name; OpenXMLDocument(FileName,XMLDocument); ImportXMLFile(FileName); UNTIL XMLFile.NEXT = 0; END ELSE BEGIN MESSAGE('No files to import'); END; ImportXMLFile(FileName : Text[1024]) OpenXMLDocument(FileName,XMLDocument); // Initialize and Load XML Document. LoadNodeList(XMLDocument,XMLNodeList,'ORDER/HEADING'); LoadNode(XMLNodeList,XMLNode,0); // Load Node Number 1 (0 = 1) from Node List. MessageValues(XMLNode.selectNodes('DEPT').item(0).text); MessageValues(XMLNode.selectNodes('NO').item(0).text); OpenXMLDocument(FileName : Text[1024];VAR XMLDocument : Automation "'Microsoft XML, version 2.0'.DOMDocument") // Initialize and Load XML Document. // General Function. IF ISCLEAR(XMLDocument) THEN // Initialize CREATE(XMLDocument); XMLDocument.load(FileName); // Load XML File MessageValues(FieldValue : Text[1024]) MESSAGE(FieldValue); // Just displaying the values on screen. LoadNodeList(XMLDocument : Automation "'Microsoft XML, version 2.0'.DOMDocument";VAR XMLNodeList : Automation "'Microsoft XML, version // Load Node List from XML Document. // General Function. XMLNodeList := XMLDocument.getElementsByTagName(ElementName); LoadNode(XMLNodeList : Automation "'Microsoft XML, version 2.0'.IXMLDOMNodeList";VAR XMLNode : Automation "'Microsoft XML, version 2.0' // Load Node from Node List. // General Function. XMLNode := XMLNodeList.item(RecordIndex);
Regards
Christian0 -
Thanks fpr input guys, this one did the trick:
REPEAT FileName := FileLocInbox + XMLFile.Name; ImportXMLFile(FileName); MoveXMLFile; UNTIL XMLFile.NEXT = 0;
Regards
Christian0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions