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?
Rallnus (Yamaha FJ1200 - '89 / 25th anniversary was great!)
0
Answers
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>
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 it