I'm using xmllint --shell to inspect a very large XML file. I've written an XPath query that returns the results that I want, but in order to view and save the results, I'm having to cd to each node and then write filename.xml. This wouldn't be so bad if I didn't have to search each time, selecting the result index that I want. Example:
xpath count(/root/entry/subentry[special_id = /root/entry/subentry/special_id])
Object is a Node Set :
Set contains 121 nodes:
cd (/root/entry/subentry[special_id = /root/entry/subentry/special_id])[1]
write node1.xml
cd (/root/entry/subentry[special_id = /root/entry/subentry/special_id])[2]
write node2.xml
cd (/root/entry/subentry[special_id = /root/entry/subentry/special_id])[3]
write node3.xml
...
cd (/root/entry/subentry[special_id = /root/entry/subentry/special_id])[121]
write node121.xml
The above is more or less what I'm doing. Is there a way to save the XML nodes out as a file straight from the search without having to cd to them individually and continue to repeat the search? Or is there a way to preserve the search results, or get their position numbers in one query?