Home > Ax Technical > Converting a System.Xml.XmlDocument to XML type in Dynamics ax

Converting a System.Xml.XmlDocument to XML type in Dynamics ax

When interacting with .Net assemblies mostly  Xml is used to send/receive outputs from the external system. Here is a code snippet that tells how to convert a System.Xml.XmlDocument to a Xml string in Ax which you can use for further processing by classes like XmlDocument…

//CLR Objects
System.Xml.XmlDocument document;
System.Xml.XmlTextWriter textWriter;
System.IO.StringWriter   stringwriter;

//X++ Objects
Xml                      Xml
;

//call to the .Net assembly that returns a XML
document    = processINput(...argument..)

stringWriter = new System.IO.StringWriter();
textWriter   = new System.Xml.XmlTextWriter(stringwriter);

document.writeTO(textWriter);

//Converted to Ax Xml format here
xml        = stringWriter.ToString();

Advertisements
  1. April 21, 2010 at 1:20 pm

    Another way of doing it…

    //CLR Objects
    System.Xml.XmlDocument document;
    System.Xml.XmlNode node;

    //X++ Objects
    Xml Xml
    ;

    //call to the .Net assembly that returns a XML
    document = processINput(…argument..)
    node = document.getXml();

    xml = ClrInterOp::getAnyTypeForObject(dNode.get_OuterXml());

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: