Documention for: xml-dom.r
Created by: chrisrg
on: 16-Dec-2008
Last updated by: chrisrg on: 29-Mar-2009
Format: html
Downloaded on: 26-Apr-2024

XML/DOM

1. Introduction

An XML/DOM interface designed for intuitive access to XML values.

Features

utilizes REBOL datatypes to represent XML structure; DOM methods for extraction; self-contained and works with /Base; prettified block structure.

Caveats

destructive - discards whitespace and comments; does not preserve empty tags vs. matching tags with no content; NOT an implementation of W3 DOM, only a loosely inspired subset.

To Do

saving.

2. Usage

An example session:

    >> test: {<a><b><c id="d">Text</c><c id="e" /></b></a>}
    == {<a><b><c id="d">Text</c><c id="e" /></b></a>}
    >> load-xml test
    == [
        <a> [
            <b> [
                <c> [
                    /id "d" 
                    # "Text"
                ] 
                <c> [
     ...
    >> doc: load-xml/dom test
    >> length? doc/get-by-tag <c>
    == 2
    >> c: doc/get-by-id "d"
    >> c/text
    == "Text"
    >> doc/tree/<a>/<b>
    == [
        <c> [
            /id "d" 
            # "Text"
        ] 
        <c> [
            /id "e"
        ]
    ]
    >> e: c/sibling/after
    >> e/text
    == none
    >> e/get /id
    == "e"
    >> c/sibling/before
    == none