Create xml node in document with default namespace

M

Martin

Hi,

I would appreciate some help with creating an xml node in a document and
automatically setting the default namespace

The code below loads an xmnldocument with a default namespace --
xmlns=""http://mydomain.org/schema.xsd""

however when i create a nod in it below the node come out with a blank
string set for the "xmlns" attribute.

can anybody suggest how to populate the attribute "xmlns" with
"http://mydomain.org/schema.xsd"


XmlDocument xmldoc = new XmlDocument() ;
xmldoc.LoadXml( @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<root xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns=""http://mydomain.org/schema.xsd"">
</root>") ;

XmlNode AddNode;
AddNode = xmldoc.CreateElement( "Trial" ) ;

xmldoc.DocumentElement.AppendChild( AddNode ) ;

xmldoc.Save( Console.Out ) ;


many thanks in advance

cheers

martin.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top