473,508 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing xmlns:xsd and xmlns:xsi when using ImportNode

I'm doing some document merging where I want to bring in an XmlDocument and
import its document element into another document deeper in its tree.
However, when serializing my underlying objects, .Net likes to add these
namespaces:
<RootNode xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ChildNode xmlns="MyObjectHierarchyNamespace/>
</RootNode>

The problem this is causing me is that any node(s) that have those
namespaces get properly imported into the XML, but those nodes fail to
deserialize. Is there a wya to prevent the aforementioned namespace issue
(in either importation or deserialization) without manually removing the
attributes during merging?
Feb 22 '07 #1
3 7252
"Keith Patrick" <ri*******************@nospam.hotmail.comwrote in message
news:uR**************@TK2MSFTNGP05.phx.gbl...
I'm doing some document merging where I want to bring in an XmlDocument
and import its document element into another document deeper in its tree.
However, when serializing my underlying objects, .Net likes to add these
namespaces:
<RootNode xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ChildNode xmlns="MyObjectHierarchyNamespace/>
</RootNode>

The problem this is causing me is that any node(s) that have those
namespaces get properly imported into the XML, but those nodes fail to
deserialize. Is there a wya to prevent the aforementioned namespace issue
(in either importation or deserialization) without manually removing the
attributes during merging?

Keith, if they fail to deserialize, it's probably because you don't have the
correct namespaces declared on the properties they should deserialize into.
For instance, what namespace do you have declared on the ChildNode property?

In other words, this is more likely because of the
xmlns="MyObjectHierarchyNamespace" rather than because of the xmlns:xsd or
xmlns:xsi namespace nodes.

Here's a very brief lesson on XML namespaces, in case you need it:

<foo xmlns="bar"/>

and

<foo xmlns="baz"/>

Are elements of two totally different and unrelated types. If you had a
property that the first one deserialized into, you would not want the second
one to be able to deserialize into that same property, because it's a
totally different entity that happens to also have the local name "foo".

John
Feb 23 '07 #2
I've got all my classes tagged with XmlType("MyObjectHierarchyNamespace")
but not the properties of those types. But the thing is, my namespace is
already being declared on the primary document so that when it merges in,
I'll have:

<Grades xmlns="MyObjectHierarchyNamespace">
<Grade Name="1st">
<Subjects>
<Subject Name="Math">
<Segments>
<Segment Name="SegmentOne" />
</Segments>
</Subject>
<Subject Name="English">
<Segments>
<Segment Name="SegmentOne">
<Modules>
<Module
xmlns="MyObjectHierarchyNamespace"/>
<Module />
<Module />
</Modules>
Feb 23 '07 #3
Ahh, found a fix. I was using XmlTypeAttribute, but converting to
XmlRootAttribute wound up working.

Feb 23 '07 #4

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

Similar topics

1
1522
by: ksampson | last post by:
I simply want to generate an XML document. I want the root element to include an attribute like <rootElement xmlns:xsd="http://someurl"> .... </rootElement> --- With: <xsl:element...
2
2382
by: Julia | last post by:
Hello How can i control the serialize result? I dont need <?xml version="1.0" encoding="utf-8" ?> and "xmlns:xsd=http://www.w3.org/2001/XMLSchema...
0
1887
by: chris.stromberger | last post by:
New to SOAP. I am working on something that uses the paypal web services. All the examples have this as the first portion of the soap doc <?xml version="1.0" encoding="UTF-8"?>...
1
9086
by: aevans1108 | last post by:
Greetings All If this is the wrong place to post this question, please give me a push in the right direction. Thanks. I know there has to be a simpler way to do this, but this is as simple a...
3
7124
by: Keith Hill | last post by:
I am creating an XmlDocument in code and then using XmlTextWriter via doc.WriteTo(xwriter) to output the result to a text box. I have a root element that defines a default namespace. However, the...
1
12585
by: Jack Colletta | last post by:
Hello, If I have a xml document with a rootlevel <workOrderReleased xmlns="http://www.qad.com/qdoc" xmlns:enc="http://www.w3.org/2002/12/soap-encoding"...
4
7696
by: =?Utf-8?B?UmFqaXY=?= | last post by:
Hi, I have a webservices(developed in .net 2.0, using c#) with a webmethod that returns a XML document. The problem is that the XML returned from the webservice is having a attribute xmlns="" in...
2
20385
by: =?ISO-8859-1?Q?Norbert_P=FCrringer?= | last post by:
Hello, I use Xml serialization to serialize an object into an xml file. My root tag is defined as following:
2
3918
by: killy971 | last post by:
I am using java to validate an XML file with a DTD, without having the DVD declaration inside the original file, by setting the doctype dynamically to a transformer like this : ...
0
7233
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
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
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
7505
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...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.