all groups > dotnet xml > december 2004 >
You're in the

dotnet xml

group:

Namespace references in XML Serialization


Namespace references in XML Serialization MattBell
12/29/2004 9:29:03 AM
dotnet xml:
I have an object which serializes to XML. It's root node references the
namespace I'm working with, but I would like to preferace the root node with
a namespace reference (ie ns1:RootNode) is there a way to do this with
XmlAttributes?
Re: Namespace references in XML Serialization Dino Chiesa [Microsoft]
1/3/2005 12:50:10 PM
how do you serialize?

If you are using .NET's XML serialization, you can use
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add( "ns1", "urn:WhateverYouLike" );

to specify a prefix and map it to a particular XML namespace.

Then serialize with something like
XmlSerializer s1 = new XmlSerializer(typeof(TheType));
s1.Serialize(TheTextWriter, TheInstance, ns);

Does this do what you want?

-D

[quoted text, click to view]

AddThis Social Bookmark Button