Martin Honnen said:
Well how exactly do you want to identity duplicates? Based on certain
element or attribute value like an id element or attribute? Does the
schema define an id attribute or a key elements?
Well,
Here's how I build an XML file ...
public void RecursivelyBuildDescendentTree()
{
XElement OriginalPerson =
new XElement ("Person",
new XElement ("Name", "Bob"));
XElement Child1 =
new XElement ("Person",
new XElement ("Name", "John"));
XElement Child2 =
new XElement ("Person",
new XElement ("Name", "Jane"));
XElement Girlfriend1 =
new XElement ("Person",
new XElement ("Name", "Sally"));
XElement Girlfriend2 =
new XElement ("Person",
new XElement ("Name", "Kelly"));
}
public void test()
{
XElement root = new XElement("Root");
XElement rootPerson = RecursivelyBuildDescendentTree();
}
I'm not building a family tree, but it's the same idea. The tree starts out
with a person, and each person can have 0 or more children, and 0 or more
girlfriends. I would basically want to merge 2 files like this based on the
person's name. I have no xsd file, the schema is built right into the code
(as shown above). I know I should be verifying it, but I'm not right now.
I'm just looking to get this working first.
Right now I'm working on adding some type of merge method that will take 2
XElement structures, and manually go through 1 and determine if a person is
not in the other. If not, then it will add the person and all of that
person's children and girlfriends.
Seems like there is a better way though. I also feel like this is going to
be really slow when I'm finished.