How to convert a generic xml format block to properties format String from an xml file using ksh script

With the conditions:

  1. I cannot use any XML parser tool as I don't have permission , read only

  2. My xmllint version does not support xpath, and I cannot update it , read only

  3. 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.


let's assume


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:


 <bike>Mountain bike</bike>

So the thing that I want to achieve here is to get the xml block that satisfies my search ,

for example NAME=Bob ;

The output of the script should be in properties file format


A thing to consider here is that the xml format per block are different. The nodes are not the same for every xml block.


With bash and GNU sed:


sed -n '/name>'${NAME}'/,/<\/block>/s/.*<\(.*\)>\(.*\)<.*/\1=\2/p' file.xml



Need Your Help

Android UI layout component resizing wrongly on font size change

android xml android-layout layout

I have a layout with 3 components that align perfectly as long as the user doesn't change the font size in display settings on their android phones...

Why is jsPDF outputing only blank pages on larger documents?

javascript jquery canvas jspdf html2canvas

I have a function that calls html2canvas. If the canvas is only 1 pdf 'page' large it works no problem. If it is larger than that I made this while statement to break up the canvas into smaller can...