xpath - how to select multiple nodes based on value



I have some xml and I would like to dynamically extract some information, based on some incoming data.


Here is some xml:



<?xml version="1.0" encoding="UTF-8"?>
<releaseNote>
<name>DECOUPLING_client</name>
<change>
<date hour="12" day="24" second="44" year="2012" month="10" minute="46"/>
<submitter>Automatically Generated</submitter>
<description>ReleaseNote Created</description>
</change>
<change>
<version>0-2</version>
<date hour="12" day="24" second="48" year="2012" month="11" minute="46"/>
<submitter>fred.darwin</submitter>
<description> first iteration of decoupling client - copied files from old decoupling module</description>
<install/>
</change>
<change>
<version>0-3</version>
<date hour="16" day="25" second="34" year="2012" month="11" minute="52"/>
<submitter>fred.darwin</submitter>
<description> promoting changes</description>
<install/>
</change>
</releaseNote>


And I'd like to pass in the string '0-2' and find out all versions since 0-2 like this:



0-3 fred.darwin 25/11/2012 promoting changes


It's complicated by the fact that the numbers I'm comparing start with '0-'.


However luckily you can remove the '0-' and get a real number, which corresponds to a position, so I've got as far as something like this:



xmllint --xpath '/releaseNote/change[position()>2]/description/text() ${file}


which just concatenates all the descriptions and spits them out.


How do I loop through them and select multiple node content?


No comments:

Post a Comment