Hi Roneo,
The following awk script eliminates spaces between nodes like you want (i hope).
awk -f CleanUp.awk XMLfile
----- XMLfile -----
Your <B>identification</B> :
<IDENT>
<NAME>James Brown</NAME>
No more informations
</IDENT>
-------------------
----- Result -----
Your <B>identification</B> :
<IDENT><NAME>James Brown</NAME>
No more informations
</IDENT>
------------------
----- CleanUp.awk -----
# Supress spaces between consecutive nodes
# in the same line
{
gsub(">[ \t]*<","><",$0)
}
# After une line ending with a node,
# memorize empty line and go to to next line
AfterNode && /^[ \t]*$/ {
Memo[++MemoCnt]=$0
next
}
# After une line ending with a node,
# merge this previous line with current
# if starting with a node
AfterNode && /^[ \t]*</ {
gsub("^[ \t]*<","<",$0)
$0=Node $0
MemoCnt=0
AfterNode=0
}
# After une line ending with a node,
# print all memorized lines if the
# current line is not starting with a node
AfterNode && /^[ \t]*[^<]/ {
for (im=1; im<= MemoCnt; im++)
print Memo[im]
MemoCnt=0
AfterNode=0
}
# When a node is ending the line
# memorize it, it will be printed later
# Go to next line
/>[ \t]*$/ {
AfterNode=1
MemoCnt=0
Memo[++MemoCnt]=$0
gsub(">[ \t]*$",">",$0)
Node=$0
next
}
# No special case, print current line
{
print $0
}
# End of file, if we are after a line ending
# with a node, print all memorized lines
END {
if (AfterNode) {
for (im=1; im<= MemoCnt; im++)
print Memo[im]
}
}
-----------------------
Jean Pierre.