473,657 Members | 2,805 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="MyObject HierarchyNamesp ace/>
</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 7265
"Keith Patrick" <ri************ *******@nospam. hotmail.comwrot e in message
news:uR******** ******@TK2MSFTN GP05.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="MyObject HierarchyNamesp ace/>
</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="MyObject HierarchyNamesp ace" 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("MyObje ctHierarchyName space")
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="MyObject HierarchyNamesp ace">
<Grade Name="1st">
<Subjects>
<Subject Name="Math">
<Segments>
<Segment Name="SegmentOn e" />
</Segments>
</Subject>
<Subject Name="English">
<Segments>
<Segment Name="SegmentOn e">
<Modules>
<Module
xmlns="MyObject HierarchyNamesp ace"/>
<Module />
<Module />
</Modules>
Feb 23 '07 #3
Ahh, found a fix. I was using XmlTypeAttribut e, but converting to
XmlRootAttribut e 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
1534
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 name="rootElement" namespace="http://someurl">
2
2407
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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" in the following example: <?xml version="1.0" encoding="utf-8" ?>
0
1895
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"?> <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
1
9104
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 way as I could come up with. Yes, it's obvious I don't know what I'm doing. I'm creating an XSD string and an XML string at runtime (ie: NOT read
3
7136
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 sub-elements are created without any namespaces like so: XmlElement elem = doc.CreateElement("Foo"); root.AppendChild(elem); but in the output I get this:
1
12674
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" xmlns:qcom="http://www.qad.com/qdoc/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="workOrderReleasedWithComments-JITS17_1.xsd">
4
7717
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 the root node. It seems that ..net framework is adding this attribute as I have not adding this attribute through my code. Is it possible to remove this attribut from the response XML? I know can be possible to remove it at the client side,...
2
20462
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
3926
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 : transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, dtd); transformer.transform(source, new StreamResult(new StringWriter())); I would like to know if there is a way to validate an XML file with an XSD, again, without having the declaration of the xsd file...
0
8403
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8737
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
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 we have to send another system

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.