shell - xml read many values and echo them in sh -



shell - xml read many values and echo them in sh -

i have xml variable named xml this:

<m:rgwspublicfirmactrtuser> <m:firmactdescr>text</m:firmactdescr> <m:firmactkind>2</m:firmactkind> <m:firmactkinddescr>text</m:firmactkinddescr> <m:firmactcode>47191000</m:firmactcode> </m:rgwspublicfirmactrtuser>

and echo them command

#!/bin/sh echo $xml | grep -o -p '(?<=<m:firmactdescr>).*(?=</m:firmactdescr>)' echo "something"

and get

text

but have same more 1 values , xml this:

<m:rgwspublicfirmactrtuser> <m:firmactdescr>text</m:firmactdescr> <m:firmactkind>2</m:firmactkind> <m:firmactkinddescr>text</m:firmactkinddescr> <m:firmactcode>47191000</m:firmactcode> </m:rgwspublicfirmactrtuser> <m:rgwspublicfirmactrtuser> <m:firmactdescr>text2</m:firmactdescr> <m:firmactkind>3</m:firmactkind> <m:firmactkinddescr>text2</m:firmactkinddescr> <m:firmactcode>47191000</m:firmactcode> </m:rgwspublicfirmactrtuser>

and text3 , on.

how cam create programme show:

text1 text2 text3

and show on

i cant utilize previous method more, meaby utilize "while" , xml command values? thx!

the best solution here xsltproc - xslt perfect processing xml:

printf "$xml" | xsltproc firmactdescr.xslt -

in xslt file, utilize xsl:value-of value, xsl:text print something , <xsl:output method="text" omit-xml-declaration="yes" indent="no"/> print plain text.

xml shell cgi sh xmllint

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -