> 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.
[quoted text clipped - 10 lines]
> (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
Keith Patrick - 23 Feb 2007 15:39 GMT
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>
.
.
.
In this case, everything shows up except that first module (Modules contains
2 Module objects). public class Module has
XmlType("MyObjectHierarchyNamespace") as does ModuleCollection, but not the
property Modules
Keith Patrick - 23 Feb 2007 15:53 GMT
Ahh, found a fix. I was using XmlTypeAttribute, but converting to
XmlRootAttribute wound up working.