bash - XPath to list available tags non recursively (using xmllint in a shell script) -
i'm trying build xpath argument utilize in programme xmllint (used within bash shell script) homecoming list of available tags within tag (while not listing subtags).
here's sort of xml have:
<functioninformation> <class> setup </class> <description> natural language description of function. </description> <prerequisitefunctions> myfunction1 myfunction2 </prerequisitefunctions> <prerequisiteprograms> myprogram1 myprogram2 </prerequisiteprograms> </functioninformation>
this xml stored in bash variable functioninformation.
the output have when using xmllint on xml following:
class description prerequisitefunctions prerequisiteprograms
i should note tags returned in non recursive way (i not want available tags or subtags listed).
i can access info in tags using xmllint in way such following:
descriptionfunctioninformation="$(echo "${functioninformation}"\ | xmllint --xpath '/functioninformation/description/text()' -\ | xargs -i echo -n "{}")"
could point me in right direction on how may build xpath (or similar) homecoming info need?
you can utilize xmlstarlet
:
xmlstarlet sel -t -m '/*/*' -v 'concat(name(.)," ")' < xmlfile
bash list xpath tags
No comments:
Post a Comment