I’m trying to build XmlDocument so that after serialization I could achieve something like this xml:
<?xml version="1.0" encoding="UTF-8"?>
<wnio:element xmlns:wnio="somuri" xmlns:xf="abcd">
<xf:nestedelement>somtext</xf:nestedelement>
</wnio:element>
The things is that XmlElement allows to specify ONLY ONE namespace via NamespaceURI and Prefix properties. How can I accomplish this kind of functionality?
The attributes “xmlns:wnio” and “xmlns:xf” are attributes like any other. Simply add them to the XmlElement that you would like these XML Namespaces to scope to.
The following snippet produces almost exactly what you want: