Hi,
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="RW_8987"
dept_id="D_12"
main="false">
<Person id="P_0001"
email="email0001@example.com"
username="person_0001"
password="pass_0001"/>
<Person id="P_0002"
email="email0002@example.com"
username="person_0002"
password="pass_0002"/>
<!-- ... -->
</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.
Can you kindly suggest what how I can achieve this. Thanks in advance.