Joel wrote:
> Adding "length" attribute/value data to the <block> tag is left as an
exercise to the reader.

[
Rebol []

XML: func [Block [block!]] [
    ML Map Block func [Value] [
        reduce any [
            if block? Value [
                ['block/length length? Value XML Value]
                ]
            [to-word form type? Value form Value]
            ]
        ]
    ]

probe XML reduce [
    [25 87 20] 13/Oct/2002 [[1 3 5] [2 4 6]]
    "That's all, folks!"
    ]

halt
]
Which generates:
{<block
length="3"><integer>25</integer><integer>87</integer><integer>20</integer></
block><
date>13-Oct-2002</date><block length="2"><block
length="3"><integer>1</integer><integer>3</
integer><integer>5</integer></block><block
length="3"><integer>2</integer><integer>4</integ
er><integer>6</integer></block></block><string>That's all, folks!</string>}

Watch out for line breaks!

I didn't worry about nice padding and I haven't checked for "<" and ">" and
"&" values. I've left object! values as an exercise for the reader, as this
depends more upon the receiver. :)

Andrew Martin
ICQ: 26227169 http://valley.150m.com/
-><-

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to