472,802 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Namespace references in Xml Serialization

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 there a way to do this in C#?

Also can I include other namespaces in this declaration as well?
Nov 12 '05 #1
1 1321
Matt,

I answered that question here in the group just yesterday ;):
The best way is to pass an XmlSerializerNamespaces object to the
Serialize() method, as I describe in [0].

You could also modify the generated class to force the namespace prefix
when serializing instances [1], but I am generally not a friend of
modifying generated code

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

[0] http://www.topxml.com/xmlserializer/...at_runtime.asp
[1] http://www.topxml.com/xmlserializer/...namespaces.asp
-----Original Message-----
From: MattBell [mailto:Ma******@discussions.microsoft.com]
Posted At: Wednesday, December 29, 2004 11:23 AM
Posted To: microsoft.public.dotnet.xml
Conversation: Namespace references in Xml Serialization
Subject: Namespace references in Xml Serialization

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 there a way to do this in C#?

Also can I include other namespaces in this declaration as well?


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 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...
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,...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.