Rashed Amini

The ara3n weblog

How to remove Namespaces in XMLport in NAV 2013

7th December 2012

MS in Dynamics NAV 5.0 created XMLPort datatype. It was a great tool to load xml files but it had trouble dealing with namespaces. MS released a workaround code for this that allowed removing all the namespaces of the xml file. The Code looked like this.

OldRemoveNameSpaces

In Dynamics NAV 2013 32 bit com objects are no longer supported on service tier and the suggestion from MS is to move to dotNET data types for automation. I’ve used the above solution in many of my projects and I’m sure many partners have used this for your existing solutions. When you are going to upgrade you will run into this code and will need to be upgraded to System.xml dotNET data type. The problem that partners will have is trying to implement transformNodeToObject function. I’ve provided a solution below that allows you to do the same process for System.xml.

RemoveNameSpaces

So your XML files will look before the transformation like this.

XMLFilewithNameSpaces

And after transformation like this.

XMLFIleNoNameSpaces

Attached is the CU object

Comments are closed.