With the conditions:
I cannot use any XML parser tool as I don't have permission , read only
My xmllint version does not support xpath, and I cannot update it , read only
I dont have xmlstarlet and cannot install it
My options are limited to almost String processing.
An input parameter will be provided by the user and it will be the name of the block.
and we will use
$NAME as the parameter to search the xml block that will be searched.
How can I convert a generic xml block like this in an xml file like this:
<block> <name>Bob</name> <address>USA</address> <email>firstname.lastname@example.org</email> <phone>1234567</phone> </block> <block> <name>Peter</name> <food>France</address> <cell>email@example.com</cell> <drinks>Coke</drinks> <car>Honda</car> <bike>Mountain bike</bike> </block>
So the thing that I want to achieve here is to get the xml block that satisfies my search ,
The output of the script should be in properties file format
name=Bob address=USA firstname.lastname@example.org phone=1234567
A thing to consider here is that the xml format per block are different. The nodes are not the same for every xml block.