473,320 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Namespace references in XML Serialization

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?

Nov 12 '05 #1
1 1196
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

"MattBell" <Ma******@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
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?

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David B. Bitton | last post by:
I am having a problem deserializing XML when the root node is missing a namespace declaration. My Type has an XmlTypeAttribute with a namespace defined. If I attempt to deserialize the XML, I get...
1
by: MattBell | last post by:
I have a root node attribute which contains a name space declaration. I'd like to put a reference onto the front of it (ie: ns1:RootNode) where ns1 is defined as the namespace I'm using. Is...
0
by: Alberto Grosso Nicolin | last post by:
We have the following XML schema: there's a root element (Response) with of a single child element (Result). ...
0
by: richwangler | last post by:
This problem should be easily reproducable if anybody has the time. I need to build the following XML programatically and decided to use the XMLSerializer. I simplified the XML (myExample.xml)...
2
by: films | last post by:
I understand the concept. Serialization of a class will add all the sub-objects of the class to the stream if there are also serializible. So say I have: class Author {
2
by: Pathogenix | last post by:
Greetings, I'm trying to fix a web service client which has been implemented in a dailywtf worthy manner. I've decided to rip all the old code out and start again from the proxy generated by...
2
by: Bob | last post by:
Just new at this, Vs 2005 Vb.net Created a new Windows control library User control project. Only 1 file UserControl1.vb No code or object in it at all yet except what was placed by default when...
32
by: toolmaster | last post by:
Since many of the modern computer languages have built-in namespace features, I can't understand why not add this feature into standard C. I've heard many people complain of the lacking of...
9
by: Mark Olbert | last post by:
I'm trying to serialize (using XmlSerializer.Serialize) a class that I generated from an XSD schema using XSD.EXE /c. The problem I'm running into is that the root element needs to be unqualified,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.