467,907 Members | 1,434 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

xmlns="" automatically generated

I have the following code:
XmlElement parent= m_xmlDoc.CreateElement("parent", "http://tempuri.org/myns");
parent.InnerXml = "<child1>text</child1><child2>text</child2>";

"http://tempuri.org/myns" is declared as the default namespace for this xml file.

When I set InnerXml above, each <child> node gets the following extra attribute: xmlns="". I'd like child nodes to inherit the default namespace instead of the empty namespace. How can I do it?

thanks,
Zhenya

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>RbJaD+v5AESOPlKWfTXI8g==</Id>
Nov 12 '05 #1
  • viewed: 1770
Share:
1 Reply
Zhenya Sigal via .NET 247 wrote:
I have the following code:
XmlElement parent= m_xmlDoc.CreateElement("parent", "http://tempuri.org/myns");
parent.InnerXml = "<child1>text</child1><child2>text</child2>";

"http://tempuri.org/myns" is declared as the default namespace for this xml file.

When I set InnerXml above, each <child> node gets the following extra attribute: xmlns="". I'd like child nodes to inherit the default namespace instead of the empty namespace. How can I do it?


Use
parent.InnerXml = "<child1
xmlns='http://tempuri.org/myns'>text</child1><child2>text</child2>";
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mike Dickens | last post: by
3 posts views Thread by Keith Hill | last post: by
5 posts views Thread by NeilL | last post: by
3 posts views Thread by ano | last post: by
reply views Thread by R. Ian Lee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.