How can i add namespace to a new element i.e. ns0:Sender?
I am trying to add a new line with namespace “ns0:”, but when I add new xelement it will not contain the ns0. I am trying with the invoke method add on xedocument with a new xelement(ns, “Sender”, “MS”), but it doesn’t work, as it will allow me to use “:” in a name.
@MarkusDS
give a try on following:
define a variable: XNS_ns0 or any other varname of your choice - datatype is : XNamesspace
set the default value to the namespace value: http://schemas.microsoft.com/dynamics/2008/01/documents/Message
on the new element try new xelement( XNS_ns0 + “Sender”, yourElementValue)
ensure following:
for faster exploration playing within watch panel / immediate panel will save time to explore the new XElement statement
@MarkusDS
your result is fine so far. Once you add this element to xmldocument where on some parent level the namespace with prefix is defined then it will come as expected.
Thanks, not sure i understand the connection between myXElement and myRootElement, but it seems the assign of myrootelement also affects myxelement and adds the namespace.