Skip to main content
1 of 2
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Assuming the following (modified) XML:

<?xml version="1.0"?>
<root>
  <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>
</root>

The XMLStarlet invocation

xml sel -t -m '//ContactPerson' -v 'concat(GivenName, " ", FamilyName, " ", PhoneFixList/PhoneFix, " ", EmailList/Email)' -nl file.xml

produces

John Wayne 78787878 [email protected]
James Stewart 90909090 [email protected]
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k