[REBOL] Re: XML-Parse
From: rebol:gavinmckenzie:fastmail:fm at: 8-Aug-2003 7:55
On Tue, 5 Aug 2003 10:42:31 +0200, "bryan" <[bry--itnisk--com]> said:
> I've thought about doing the same, mainly cause I want to have xpath in
> Rebol, and to do that I need a decent xml parser. I'm sure you're better
> qualified than me for doing it but if you need any help on the project
> I'd be glad to help.
That's basically what the xml-object.r script does. The xml-object.r
script turns the XML into a REBOL object hierarchy; the goal was to allow
you to use REBOL's path syntax into XML. It worked well enough for my
needs. It, as far as I recall, does coalesce multiple repeating XML
elements into an array and such.
Look for the heading "Multiply Occurring Elements".
Mixed content is handled too.
I use XPath in my day-job on a regular basis. XPath is the ultimate
generalized way to address into XML content. It is also overkill for
data-oriented XML content which is simpler in its intent than the set of
all possible flavours of XML. Data-oriented XML is like the data-content
from a bill/statement/purchase-order/etc. as opposed to a XHTML web-page.
When interpreting (as opposed to writing) data-oriented XML you rarely
care about whether something is actually expressed as an element or
attribute, and so REBOL's path syntax is more usable in that context than
Anyway, for me, the real power of XPath over what xml-object gives you
with REBOL paths is the ability to write queries and do tests in XML
where you can say "fetch all the "foo" elements that have a "bar"
attribute with a value between 1 and 100". xml-object doesn't give you
that capability, but it turns out that that degree of power is something
that I didn't need when I built xml-object.
In contrast, the xml-parse script is SAX oriented. It is meant to be a
lower-level *parser* interface upon which one could build a DOM-creation
script such as xml-object or some other more W3C compliant DOM script.
They're meant to be complimentary.