P
PC Paul
Hi,
I have a problem that seems like it ought to be solvable with a couple
of XPath statements but after a couple of days I can't find them..
Original XML:
<People>
<PartialPerson>
<Name>Brian</Name>
<Nickname>BB</Nickname>
</PartialPerson>
<PartialPerson>
<Name>Geoffrey</Name>
<Email>[email protected]</Email>
</PartialPerson>
<PartialPerson>
<Nickname>BB</Nickname>
<Email>[email protected]</Email>
</PartialPerson>
</People>
What I want to do is collect all of the info for a given person together
by linking equal fields: e.g. to end up with this:
<People>
<CompletePerson>
<Name>Brian</Name>
<Nickname>BB</Nickname>
<Email>[email protected]</Email>
</CompletePerson>
<CompletePerson>
<Name>Geoffrey</Name>
<Email>[email protected]</Email>
</CompletePerson>
</People>
The actual data might have 6+ fields, and I don't know which will be
filled in each time. Each of the fields is guaranteed to have unique
contents within the XML file, so what I need to do is to link together
all of the child elements from any other PartialPerson where any of it's
children match the equivalent child of this one. If you see what I mean.
I've got close by doing a for-each over all of the Name fields and
collecting all others with the same Name ec., but because there is no
field that is always present I end up having to go round again and again
to catch all of the cases, and with 6 child elements to consider it
grows to ridiculous proportions.
Ummm.... Help??
I have a problem that seems like it ought to be solvable with a couple
of XPath statements but after a couple of days I can't find them..
Original XML:
<People>
<PartialPerson>
<Name>Brian</Name>
<Nickname>BB</Nickname>
</PartialPerson>
<PartialPerson>
<Name>Geoffrey</Name>
<Email>[email protected]</Email>
</PartialPerson>
<PartialPerson>
<Nickname>BB</Nickname>
<Email>[email protected]</Email>
</PartialPerson>
</People>
What I want to do is collect all of the info for a given person together
by linking equal fields: e.g. to end up with this:
<People>
<CompletePerson>
<Name>Brian</Name>
<Nickname>BB</Nickname>
<Email>[email protected]</Email>
</CompletePerson>
<CompletePerson>
<Name>Geoffrey</Name>
<Email>[email protected]</Email>
</CompletePerson>
</People>
The actual data might have 6+ fields, and I don't know which will be
filled in each time. Each of the fields is guaranteed to have unique
contents within the XML file, so what I need to do is to link together
all of the child elements from any other PartialPerson where any of it's
children match the equivalent child of this one. If you see what I mean.
I've got close by doing a for-each over all of the Name fields and
collecting all others with the same Name ec., but because there is no
field that is always present I end up having to go round again and again
to catch all of the cases, and with 6 child elements to consider it
grows to ridiculous proportions.
Ummm.... Help??