PhilN
07-04-2009, 12:21 AM
Now, I'm sure that a variation of this question has been asked a thousand times in different forums including this one. But, my situation is kind of unique, and would really appreciate some help on this.
This is my situation. Say this is file one:
<rootu>
<MainID>5555</MainID>
<fileversion>1.003</fileversion>
<mainu Important="True">
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<Content2>Content</Content2>
</mainu>
<mainu Important="True">
<ID>2432</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<Content2>Content</Content2>
</mainu>
<mainu Important="False">
<ID>4444</ID
<Content1>Content</Content1>
<Link>Link.htm</Link>
<Content2>Content</Content2>
</mainu>
</rootu>
A little note, the Important True/False values are something that I would like to have as an important distinguisher, but, if nobody can come up with a way to help me based on using such a distinguishing mechanism, than at the least, I still would loved to be helped based on the same idea, but with no Important value as a distinguisher (as if I never even included that). I will further explain important value in a second, but first...
This is file 2:
<rootu>
<fileversion>1.22</fileversion>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>6783</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>1112</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>2432</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>4444</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
</rootu>
Now, it might already be obvious what I want to do, but, I'll show it, this is what I want the resulting newly merged xml file to look like:
<rootu>
<MainID>5555</MainID>
<fileversion>Whatever ends up here doesn't matter...</fileversion>
<mainu Important="True">
<Date>2009-07-03T15:25:36Z</Date>
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
<Content2>Content</Content2>
</mainu>
<mainu Important="True">
<Date>2009-07-03T15:25:36Z</Date>
<ID>4444</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
<Content2>Content</Content2>
</mainu>
<mainu Important="True">
<Date>2009-07-03T15:25:36Z</Date>
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
<Content2>Content</Content2>
</mainu>
</rootu>
So put into words, what I need to do is merge two xml files into a third one based on matchings in the ID value inside the mainu attribute and also having as many new mainu's based matching ID values as there are in file2, no matter how many times a matching ID occurance happens with the same value (in this case "1234"). That's what I'd really like to accomplish.
Also, if anyone can even further help me, and explain how I can ONLY merge the mainu's if both the ID matches and the Important value is set to true. I know that is even more tricky, and if I can't make use of the concept, I know a way around it, so it's not as important. But, I really especially need help on what I mentioned above.
Thanks allot for any help.
This is my situation. Say this is file one:
<rootu>
<MainID>5555</MainID>
<fileversion>1.003</fileversion>
<mainu Important="True">
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<Content2>Content</Content2>
</mainu>
<mainu Important="True">
<ID>2432</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<Content2>Content</Content2>
</mainu>
<mainu Important="False">
<ID>4444</ID
<Content1>Content</Content1>
<Link>Link.htm</Link>
<Content2>Content</Content2>
</mainu>
</rootu>
A little note, the Important True/False values are something that I would like to have as an important distinguisher, but, if nobody can come up with a way to help me based on using such a distinguishing mechanism, than at the least, I still would loved to be helped based on the same idea, but with no Important value as a distinguisher (as if I never even included that). I will further explain important value in a second, but first...
This is file 2:
<rootu>
<fileversion>1.22</fileversion>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>6783</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>1112</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>2432</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>4444</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
<mainu>
<Date>2009-07-03T15:25:36Z</Date>
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
</mainu>
</rootu>
Now, it might already be obvious what I want to do, but, I'll show it, this is what I want the resulting newly merged xml file to look like:
<rootu>
<MainID>5555</MainID>
<fileversion>Whatever ends up here doesn't matter...</fileversion>
<mainu Important="True">
<Date>2009-07-03T15:25:36Z</Date>
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
<Content2>Content</Content2>
</mainu>
<mainu Important="True">
<Date>2009-07-03T15:25:36Z</Date>
<ID>4444</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
<Content2>Content</Content2>
</mainu>
<mainu Important="True">
<Date>2009-07-03T15:25:36Z</Date>
<ID>1234</ID>
<Content1>Content</Content1>
<Link>Link.htm</Link>
<newContent1>More Content</newContent1>
<newLinkText>Text</newLinkText>
<newLink>Link2.htm</newLink>
<moreContent>Information</moreContent>
<Content2>Content</Content2>
</mainu>
</rootu>
So put into words, what I need to do is merge two xml files into a third one based on matchings in the ID value inside the mainu attribute and also having as many new mainu's based matching ID values as there are in file2, no matter how many times a matching ID occurance happens with the same value (in this case "1234"). That's what I'd really like to accomplish.
Also, if anyone can even further help me, and explain how I can ONLY merge the mainu's if both the ID matches and the Important value is set to true. I know that is even more tricky, and if I can't make use of the concept, I know a way around it, so it's not as important. But, I really especially need help on what I mentioned above.
Thanks allot for any help.