I am trying to parse an XML file and keep track of certain elements to store them in an array.
An example XML file trouble.xml looks something like this:
<trouble>
<problem>
<factor name = abc/>
</problem>
<problem>
<factor name = def/>
</problem>
<trouble>
These and repeat multiple times throughout trouble.xml.
I was able to use this:
echo 'cat //factor/@name' | xmllint --shell $filename | sed -n 's: name=\"\(.*\)\":\1:p'
Output looks like this:
abc
def
This code snippet successfully prints the "names" of the factor tag. My problem now is finding a way to somehow iterate through that list of names and save them into an array?