Error during Import of XML-Files

Rallnus
Member Posts: 79
I try to import a XML-file like it is done in the example of romein.
The "LoadnodeList"-function is successful.
During "selectNodes" appears an error:
"This message ist for C/AL programmers:
This automation variable hast not been instantiated
You can instantiate it by either creating or assigning it."
Does somebody know what i shall do?
Is some literature about these problems availible?
The "LoadnodeList"-function is successful.
During "selectNodes" appears an error:
"This message ist for C/AL programmers:
This automation variable hast not been instantiated
You can instantiate it by either creating or assigning it."
Does somebody know what i shall do?
Is some literature about these problems availible?
Rallnus (Yamaha FJ1200 - '89 / 25th anniversary was great!)
0
Answers
-
post your code please ... you missed a Create() somewhere.0
-
The code is the same as in the download of emiel romein.
http://www.mibuso.com/dlinfo.asp?FileID=329
I've nly changed some variables.
When I define a new Data Type "Automation" for a parameter, this error will appear. It seems that there ist a way to define variables within a parameter of type Automation.
The modified code of emiel romein:
"XML File Name" := 'c:\Orderbeispiel4.xml'; // File name parameter.
ImportXMLItemList("XML File Name"); // Import XML File
ImportXMLItemList(FileName : Text[1024])
OpenXMLDocument(FileName,XMLDocument); // Initialize and Load XML Document.
LoadNodeList(XMLDocument,XMLNodeList,'item/ORDER_HEADER');
// Define Dialog
TotNumbOfRecs := XMLNodeList.length; // Number of "records" in XML file. TotNumbOfRecs var needed for progress dialog.
Window.OPEN(Text000);
// end define dialog
MESSAGE('%1',TotNumbOfRecs);
LoadNode(XMLNodeList,XMLNode,0); // Load Node Number 1 (0 = 1) from Node List.
REPEAT // Loop through all Nodes.
MessageValues(XMLNode.selectNodes('ORDER_ID').item(0).text); // <
XMLNode := XMLNodeList.nextNode; // Next Node Element
UNTIL ISCLEAR(XMLNode);
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);
Xml-File:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<item>
<ORDER_HEADER>
<ORDER_INFO>
<ORDER_ID>4500932746</ORDER_ID>
</ORDER_INFO>
</ORDER_HEADER>
</item>Rallnus (Yamaha FJ1200 - '89 / 25th anniversary was great!)0 -
your xql statement in selectNodes cannot catch the ORDER_ID node because the current position of XMLNode is 2 levels above <ORDER_ID>.
in your list you have all child-nodes from <ORDER_HEADER> so only <ORDER_INFO> is in the list. now you try to find <ORDER_ID> which is a child of <ORDER_INFO> and not of <ORDER_HEADER>.
try:
MessageValues(XMLNode.selectNodes('ORDER_INFO/ORDER_ID').item(0).text);
hope you understand it0 -
Thanks a lot. When you once understand the priciple, then it's no problem.Rallnus (Yamaha FJ1200 - '89 / 25th anniversary was great!)0
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