I've an xml file and am searching for a string in this file. Once (and if) the string is found I need to be able to search back to the position of another string and output the data.
ie:
<xml>
<packet>
<proto>
<field show="bob">
</proto>
</packet>
<packet>
<proto>
<field show="rumpelstiltskin">
</proto>
</packet>
<packet>
<proto>
<field show="peter">
</proto>
</packet>
My input would be known:
show="rumpelstiltskin"
and
<packet>
I need to get the following result (which is basically the second block);
<packet>
<proto>
<field show="rumpelstiltskin">
</proto>
</packet>
or
<packet>
<proto>
<field show="rumpelstiltskin">
There are thousands of (wireshark pdml conversion) and the show="rumpelstilstkin" can occur anywhere in the file and the section can be of any arbitrary size.
I've done this before and am pretty sure it's possible in an awk or sed oneliner.. any help appreciated!