Sample Header Ad - 728x90

XML parsing using xmllint and customizing the output

2 votes
2 answers
13891 views
I have xml file (say input.xml) of the following schema: I need to parse this file and write the output to another file. The required output should be of the following form: www.xyz.com\FOLDER1M\1\R1.txt www.xyz.com\FOLDER1M\2\R2.txt www.xyz.com\FOLDER2M\1\R3.txt What I have got so far is: echo 'cat /TagA/TagB/File/@*[name()="Folder" or name()="File"]' | xmllint --shell input.xml | grep '=' > xml_parsed This gives me o/p of the form: / > cat /TagA/TagB/File/@*[name()="Folder" or name()="File"] Folder="FOLDER1M\1" File="R1.txt" Folder="FOLDER1M\2" File="R2.txt" Folder="FOLDER2M\3" File="R3.txt" How should I go about getting my required output instead of this current o/p?
Asked by NGambit (525 rep)
Apr 16, 2013, 07:38 PM
Last activity: Jul 10, 2021, 04:59 PM