Reputation: 1
I am having issues while I am trying to get some data from the text filed of the xml tag.
This filed is repeated many times in the xml.
<abc>
<def>
<gh tag="ext" text="1. look
2. for
3. this
4. if
5. what">
</gh>
</def>
</abc>
What I have done is to grep the pattern and loop till the ">
reached. But I am also getting some other data also. Can someone please help me with that or show me the direction. I tried perl but XML library where missing.
Upvotes: 0
Views: 3041
Reputation: 77105
A quick and dirty solution -
awk '/text="/,/">/{print}' xmlfile | sed -e 's/^\(<gh.*="\)//' -e 's/">$//'
Upvotes: 0
Reputation: 200
sgrep - Structured Grep - used in searching and indexing XML , HTML.
http://www.cs.helsinki.fi/u/jjaakkol/sgrepexamples.html
Upvotes: 1
Reputation: 798666
Please use the correct tool.
$ xmlstarlet sel -t -m abc/def/gh -v @text input.xml
1. look 2. for 3. this 4. if 5. what
Upvotes: 3