Find:
<ANIMAL[^>]+?(?:NAME="([^"]+)"[^>]+LIKES="([^"]+)"|LIKES="([^"]+)"[^>]+NAME="([^"]+)"|(?:NAME|LIKES)="([^"]+)")[^>]*>
Replace:
\1 \2 \4 \3 \5
Test data :
<ANIMAL NAME="Fluffy" SPECIES="dog" LIKES="bones" AGE="6">
<ANIMAL LIKES="Banana" NAME="Abu" SPECIES="Monkey" AGE="6">
<ANIMAL NAME="Fluffy" SPECIES="dog" LIKES="" AGE="6">
<ANIMAL LIKES="Banana" NAME="" SPECIES="Monkey" AGE="6">
<ANIMAL AGE="6" NAME="Peter" SPECIES="Rabbit" >
<ANIMAL SPECIES="Rabbit" AGE="6" LIKES="Carrots">
Extract:
Fluffy bones
Abu Banana
Fluffy
Banana
Peter
Carrots
In case you will want to remove the leading spaces.
Find:
^\s+
Replace:
<empty>
If it gets more complicated than that maybe you should go for more advanced XML parsing tools.
Regular expressions are not the best fit for those cases.
HTH
Jean Jourdain