You cannot reliably use line/regex-oriented tools like sed/awk/shell-scripting on arbitrary xml, due to its flexible format and nested nature. You really need to use something that has a built-in xml parser, like
xmlstarlet.
http://xmlstar.sourceforge.net/
If you would provide an actual example of
valid xml, then I may be able to give you a solution.
xmlstarlet pukes on what you provided above and refuses to work.
And please use ***
[code][/code] tags*** around your code and data when you do, to preserve formatting and to improve readability. Please do
not use quote tags, bolding, colors, or other fancy formatting.
Edit:
After changing the above to this:
Code:
<XML>
<ild id="1" name="dd" status="success" ip="12.4.5.6"/>
<ild id="1" name="we" status="success" ip="12.4.5.6"/>
<ild id="1" name="fred" status="success" ip="12.4.5.6"/>
<ild id="1" name="gerd" status="success" ip="12.4.5.6"/>
</XML>
I can now use xmlstarlet like this:
Code:
$ xmlstarlet sel -t -m '//ild' -v '@name' -n file.xml
dd
we
fred
gerd