Using MSXML with Navision 3.70

kaybeekaybee Member Posts: 49
Basically I'm trying to make use of this automation.

I've installed MSXML6.dll on the Navision server itself and on the terminal servers for which users log onto. I've "regsvr32 msxml6.dll" on both servers. And I'm still getting this error:

[ Error ]

Not sure if I am coding this properly but here's the "Globals":
RootElement	Automation	'Microsoft XML, v6.0'.IXMLDOMElement	
SubRootElement	Automation	'Microsoft XML, v6.0'.IXMLDOMElement	
MemberElement	Automation	'Microsoft XML, v6.0'.IXMLDOMElement	
XMLDom		Automation	'Microsoft XML, v6.0'.DOMDocument

and here's the code:
CREATE(XMLDom);
CREATE(RootElement);
CREATE(SubRootElement);
CREATE(MemberElement);
XMLDom.loadXML('C:\Documents and Settings\kbc\Desktop\Work\Dev\Visual Basic\LabelMaker\LabelPrints\Labels.xml');
RootElement := XMLDom.documentElement;
SubRootElement := XMLDom.createElement('label');
RootElement.appendChild(SubRootElement);
MemberElement := XMLDom.createElement('value1');
SubRootElement.appendChild(MemberElement);
MemberElement.text := 'KBC';
XMLDom.save('C:\Documents and Settings\kbc\Desktop\Work\Dev\Visual Basic\LabelMaker\LabelPrints\Labels.xml');

Comments

  • ta5ta5 Member Posts: 1,164
    You have to use the create statement for xmlDom only, the other ones are created when assigned by ":=".
    Hope this helps
    Thomas
  • kaybeekaybee Member Posts: 49
    ta5 wrote:
    You have to use the create statement for xmlDom only, the other ones are created when assigned by ":=".
    Hope this helps
    Thomas

    Thanks, after rectifying the above, I keep getting an error on this line:
    RootElement.appendChild(SubRootElement);
    
    This Automation variable has not been instantiated. You can instantiate it by either creating or assigning it.
    

    I'm not familiar with this, is this something to do with the SubRootElement?
  • ta5ta5 Member Posts: 1,164
    Have a look to codeunit 6224, for example function AddElement. Then use this function directly if the license does allow it or make a copy of the function.
    In 3.7 there are a lot of examples about using DOM in the BizTalk codeunits in the 890085xx-Range.

    Don't hesitate to ask again if it doesnt work.

    Hope this helps
  • kaybeekaybee Member Posts: 49
    ta5 wrote:
    Have a look to codeunit 6224, for example function AddElement. Then use this function directly if the license does allow it or make a copy of the function.
    In 3.7 there are a lot of examples about using DOM in the BizTalk codeunits in the 890085xx-Range.

    Don't hesitate to ask again if it doesnt work.

    Hope this helps

    Unfortunately we don't have the license to view the codeunit 6224. And I can't see the other 890085 ones.

    From the above code, can I not append nodes to the root? How should this be done properly?

    I just want to be able to keep appending "<label>" to the root "<labels>". i.e.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <labels>
       <label></label>
       <label></label>
       <label></label>
    </labels>
    
  • ta5ta5 Member Posts: 1,164
    Use this function (copy from cu6224) and adapt if for your needs.

    AddElement(VAR XMLNode : Automation "'Microsoft XML, v3.0'.DOMDocument";NodeName : Text[250];NodeText : Text[250];NameSpace : Text[250]
    IF NOT NormalCaseMode THEN
      NodeName := UPPERCASE(NodeName);
    NewChildNode := XMLNode.ownerDocument.createNode('element', NodeName, NameSpace);
    
    IF ISCLEAR(NewChildNode) THEN BEGIN
      ExitStatus := 50;
      EXIT;
    END;
    
    IF NodeText <> '' THEN
      NewChildNode.text := NodeText;
    
    XMLNode.appendChild(NewChildNode);
    CreatedXMLNode := NewChildNode;
    
    ExitStatus := 0;
    
Sign In or Register to comment.