Sample Header Ad - 728x90

Parsing xml into array using xmllint

0 votes
1 answer
2827 views
I have xml file with multiple `` elements, I need to extract attributes from each node and do some work on them. IS it possible to load them to array, using ksh and xmllint ? This is what I have: xml file: customer orders script: #!/usr/bin/ksh tbid="$(echo "cat /main/resources/db/table_name/@tableid" | xmllint --shell data.xml )" username="$(echo "cat /main/resources/db/table_name/@user" | xmllint --shell data.xml )" echo $tbid echo $username Output: / > ------- tableid="001" ------- tableid="002" / > / > ------- user="mike" ------- user="david" / > eventually, I want to get a kind of 2-dim array: arr,=001 arr,=mike arr,=002 arr,=david Notes: xpath is not supported in xmllint , and can't be installed. array can be represented in any other way, I just need to be able to extract and do some work.
Asked by markiz (131 rep)
Dec 17, 2015, 03:10 PM
Last activity: Oct 14, 2019, 04:02 PM