"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