Parse XML tags with attribute with SED
Hi people, I've been searching all over the net for the correct regex/command, but cant find anything..
file.xml Code:
<koko value="92029"> Code:
<xoxo value="13245"> Code:
egrep '<xoxo[\s\S]*?/xoxo>' file.xml Thanks, Adam. |
Awk would be a better next step, but I propose to use the xpath command. It's a wrapper around Perl's XML parser.
It assumes, though, that your document is valid XML. E.g.: Code:
<?xml version="1.0"?> Code:
jameson@yellow:~$ xpath -q -e '/root/xoxo' input.xml |
Hi jhwilliams, thanks for the reply. I manage to get what I want from the xpath, but, what if it is not a valid xml file? This is because I have few data that i have to merge.
Example: Code:
cat file1.xml file2.xml > file3.xml |
Solved using sed.
Code:
sed '/<xoxo/,/<\/xoxo>/!d' notvalidxml.xml Adam. |
Removed
|
All times are GMT -5. The time now is 05:14 AM. |