MSXMLDOM6 How to add a namespace

I am reading an xml document that has a namespace (xmlns="http://www.demandware.com/xml/impex/order/2006-10-31"). Findnode does not work when the namespace is in the file. If I remove the namespace from teh xml file then findnode works. The work around is to add a namepsace using the xmldom. I know how to do this in NAV using .net (System.XML) as there is a namespacemanager and you do something like this:

XMLNamespaceMgr := XMLNamespaceMgr.XmlNamespaceManager(XMLRootNode.OwnerDocument.NameTable);
XMLNamespaceMgr.AddNamespace(Prefix,NameSpace);

How do I do this using the 'Microsoft XML, v6.0' Automation Server? Possibly something with declareprefix method?

Comments

  • jwilderjwilder Member Posts: 263
    There is some hope with:
    XMLDoc.setProperty('SelectionNamespaces','xmlns="http://www.demandware.com/xml/impex/order/2006-10-31"');

    It compiles but does not do the trick, unfortunately.
  • jwilderjwilder Member Posts: 263
    Let me rephrase my question as I am sure someone has solved this.

    In NAV 2015 Codeunit 6224 has a function called FindNodeWithNamespace. This uses dotnet System.XML library. If you go back a few versions of NAV this function did not exist in this codeunit yet. Instead of using dotnet System.XML the older version of this codeunit used automation MSXML Version 3 to accomplish the same thing. So I am trying to recreate the FindNodeWithNamespace Function using automation instead of dotnet.

    Anyone?

  • ftorneroftornero Member Posts: 524
    You can define a var like 'Microsoft XML, v6.0'.IXMLDOMElement and then use the method setAttribute to do that.

    Regards
Sign In or Register to comment.