I need to grab attributes from the XML file with pure bash script.
So I have the following XML file with a root element Group and lots of Person elements, every of them has id and username attributes. id is unique value for each element:
<?xml version="1.0" encoding="UTF-8"?>
<Group id="D_8"
main="false">
<Person id="P_0001"
email="[email protected]"
username="person_0001"
password="pass_0001"
active="true"/>
<Person id="P_0002"
email="[email protected]"
username="person_0002"
password="pass_0002"
active="true"/>
<!-- ...and hundreds of other Person elements ... -->
</Group>
And I need to use bash script to extract the id and username attributes into some key-value structure:
P_0001=person_0001
P_0002=person_0002
Checked other related answers, but most of them suggest to use some XML parsers like xmllint. But unfortunately I do not have them on the target machine.
Please suggest how I can achieve this.