Script Library: 1213 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 
View scriptLicenseDownload documentation as: HTML or editable
Download scriptHistoryOther scripts by: chrisrg

Documentation for: xml-dom.r


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