I have the following .xml and I want a specific output:
<ContactPerson> <GivenName>John</GivenName> <FamilyName>Wayne</FamilyName> <PhoneFixList> <PhoneFix>78787878</PhoneFix> </PhoneFixList> <EmailList> <Email>[email protected]</Email> </EmailList> </ContactPerson> <ContactPerson> <GivenName>James</GivenName> <FamilyName>Stewart</FamilyName> <PhoneFixList> <PhoneFix>90909090</PhoneFix> </PhoneFixList> <EmailList> <Email>[email protected]</Email> </EmailList> </ContactPerson>
Output:
John Wayne 78787878 [email protected] James Stewart 90909090 [email protected]
In some cases, I have more than two <ContactPerson>
so I would be nice to have a great loop to resolve this. I've tried to resolve the problem with a for loop but I always have the result:
John Wayne 78787878 [email protected] John Wayne 78787878 [email protected]
<PhoneMobileList>
has no end tag. This can not be parsed with an XML parser.