Microsoft XML' automation

CryoCryo Member Posts: 13
edited 2004-08-31 in Navision Attain
Hi,

I need to get information from an xml file. So I create 'Microsoft XML, v4.0' automations variables with subtype:DOMDocument, IXMLDOMNodeList, IXMLDOMNode and IXMLDOMElement.
I create this variables, using CREATE() function.

When I run my codeunit, an error is occurs on the creation of all automations variables, except DOMDocument... :(
--> the error message is like: "cannot create OLE instance control or automation server identify with GUID={...} Check the OLE control or the automation server is correctly intalled and registered"

I got the same error with all others versions of 'Microsoft XML' (2.0, 2.6,
and 3).

Does someone met this problem yet?
Why DOMDocument subtype works, and not the others? :roll:

Thank's

Comments

  • OliverTOliverT Member Posts: 37
    you don't need to do a create on every automation ;)

    i use the following code to import xml-files:

    variables:
    Name, DataType, Subtype Length
    XMLFile, File
    XMLInStr, InStream
    XMLDOMDocument, Automation, 'Microsoft XML, v3.0'.DOMDocument
    CurrNode, Automation, 'Microsoft XML, v3.0'.IXMLDOMNode
    // Opens and imports the XML
    XMLFile.OPEN(FileName);
    XMLFile.CREATEINSTREAM(XMLInStr);
    
    // Creates the XMLDOMDocument
    CREATE(XMLDOMDocument);
    
    // Loads the XML into the DOMDocument
    XMLDOMDocument.load(XMLInStr);
    
    // Closes the XML-File
    XMLFile.CLOSE();
    
    // Get the current Node
    CurrNode := XMLDOMDocument.documentElement;
    
    // Message with the current Nodename
    MESSAGE(CurrNode.nodeName);
    

    this should work.

    greetings, oliver
  • Stefan_HillmannStefan_Hillmann Member Posts: 9
    hi oliver,

    your help is totally right, but you can even use the XMLDoc.load method for directly loading a file...

    XMLDOMDocument.load(XMLFilename);
    CurrNode := XMLDOMDocument.documentElement;
    MESSAGE(CurrNode.nodeName);

    With this you don`t need to use the stream...
    This is very helpful when loading a file with unknown encoding (the most terrific theme while using navision :wink: )...


    On the other hand you should ever use the return parameter of the load call. Means:
    if not XMLDOMDocument.load(XMLFilename) then
    ERROR(XMLDOMDocument.parseError.reason)
    else ...


    Stefan
  • OliverTOliverT Member Posts: 37
    thanks! :)
  • CryoCryo Member Posts: 13
    Thank's a lot :D
Sign In or Register to comment.