.NET Interop in NAV2009 R2
February 2nd, 2012
In this forum message, I wondered why I couldn’t instantiate a System.Xml.Linq.XElement object. The constructor expected an System.Xml.Linq.XName as its parameter, but it seemed XName did not have an appropriate constructor for me to call.
It turns out that I should have studied the documentation a bit harder - there’s a static factory method Get that can provide you with a shiny new XName instance.
My code now creates the XName, based on the local name and the namespace URL. This XName is then passed to XElement’s constructor. The next step would be to add the newly created XElement to an XDocument instance. XDocument has a parameterless constructor, as well as one that accepts an array of objects (System.Object) that represents the document’s content. That’s why I add my XElement to an ArrayList first in the example below.

And this is the result:

Leave a Reply