i have a file like
<fruits>
<apple>redcolor<\apple>
<bana:rolleyes:na>yellow color and it is<\banana>
</fruits>
i need a text between apple and bannana ans so on....
how to read a text between a tags it multiple tags with differnt names
i have a file like
<fruits>
<apple>redcolor<\apple>
<bana:rolleyes:na>yellow color and it is<\banana>
</fruits>
i need a text between apple and bannana ans so on....
how to read a text between a tags it multiple tags with differnt names
This should help you with a perl script:
XML::Simple - Easy API to maintain XML (esp config files) - search.cpan.org
awk -F'[<|>]' '/<apple>/{f=1}/<banana>/{f=""}f{print $3}' file
how can i find data if multiple tags present ( i mean dynamically)
Did you try my solution?
thanx for u r ans its working
suppose in my file i have multiple lines of differnt tags
then how to get data
nawk -F">" '{print $2}' file | nawk -F"<" '{print $1}' | grep . | grep your-pattern
with this method you are not hardcoding the tagnames, instead we are getting the string between > and the following <
hence the output of this command is
sa865h@sipc306> nawk -F">" '{print $2}' file | nawk -F"<" '{print $1}' | grep .
redcolor
yellow color and it is
"grep ." will simply remove the empy lines
Hope it is useful!!!!!!!!!!!!!
thanks its working for my requirement
Like that you call nawk two times and UselessUseOfGrep once .
What about:
awk -F'[<|>]' '$3 {print $3}' file
how to get the file name also
Q)
i have a file like
<fruits>
<apple>redcolor<\apple>
<banana>yellow color and it is<\banana>
</fruits>
i need a text between apple and bannana ans so on....
how to read a text between a tags it multiple tags with differnt names