473,396 Members | 1,827 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,396 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 1337
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.