HighTechTalks DotNet Forums  

default namespace

Dotnet XML microsoft.public.dotnet.xml


Discuss default namespace in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Peter Ramsebner
 
Posts: n/a

Default default namespace - 11-06-2007 , 09:54 AM






Hi all,

does anybody know how to generate an attribute for the default namespace
like:
xmlns="http://www.xxx.com/....."

I have tried something like this:
myWriter.WriteAttributeString("xmlns", http://www.xxx.com/....)
I get the message:

"Das Präfix '' kann nicht von '' in 'http://www.ixxx.com/....'innerhalb
desselben Startelementtags neu definiert werden."

Thanks for any help

Peter



Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: default namespace - 11-06-2007 , 10:06 AM






Peter Ramsebner wrote:

Quote:
does anybody know how to generate an attribute for the default namespace
like:
xmlns="http://www.xxx.com/....."
Usually you do create such namespace declarations yourself, rather you
write the elements in the correct namespace and then the serializer
automatically outputs the namespace declaration itself e.g. this code

const string ns = "http://example.com/2007/ns1";
using (XmlWriter writer = XmlWriter.Create(Console.Out))
{
writer.WriteStartElement("root", ns);
writer.WriteElementString("foo", ns, "example");
writer.WriteElementString("bar", ns, "example 2");
writer.WriteEndElement();
}

generates this XML:
<root xmlns="http://example.com/2007/ns1"><foo>example</foo><bar>example
2</bar></root>

So make sure you write out elements in the namespace they belong to,
that way you will get namespace declarations generated.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #3  
Old   
Peter Ramsebner
 
Posts: n/a

Default Re: default namespace - 11-08-2007 , 07:44 AM



Thanks, but there are still more problems to solve...

Peter



Reply With Quote
  #4  
Old   
Martin Honnen
 
Posts: n/a

Default Re: default namespace - 11-08-2007 , 08:16 AM



Peter Ramsebner wrote:
Quote:
Thanks, but there are still more problems to solve...
We can certainly help solving if you describe what XML you want to create.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.