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/