[EMAIL PROTECTED] wrote:
>
> Maybe a refinement would be in order
> /prune-non-material-and-annoying-line-breaks :)
> Failing that I'll just have to use an if.
>
I wrote the following helper function to strip all redundant whitespace
from the nested block structure returned by parse-xml. (By "redundant",
I mean whitespace that precedes or follows non-whitespace character
data.) The function also deletes content strings that become empty upon
whitespace cleanup.
All suggestions, optimizations, etc. are welcome.
-jn-
;;===================
trim-xml: func [
b [block!]
/local
content
item
][
content: third b
if found? content [
while [not tail? content] [
item: first content
either block? item [
trim-xml item
content: next content
][
either 0 = length? trim item [
remove content
][
content: next content
]
]
]
if 0 = length? head content [
b/3: none
]
]
b
]
;;===================