InstantXML - Temporary Perl Module for DOM Level 1

Free Module
Copyright(C)1998 UENO Kojun

[Japanese]

Alternative

You'd better try the XML::DOM module first.

Feature

Download (via http)

InstantXML Ver.0.55 (latest snapshot)
SP1for053.pm (Supplement)
InstantXML Ver.0.53 (stable, Oct 21 1988)
InstantXML Ver.0.51 (beta, Oct 1988)

How to use KParser

KParser is an sample supplement. But it provides the most easy way to use this package. See the file t/sample.t and t/tester.t as an example.

Put the folder(or directory) 'InstantXML' into your library path (@INC). Put the following declaration at the begining of your script.

use InstantXML::KParser;
The following expression returns a object with the Interface 'DocumentFragment'.
InstantXML::KParser->parseFragment($string_with_xml_tags) or simply, parseFragment($string_with_xml_tags)
In current version of KParser, note that the firstChild of a fragment will be a Text node even if it is of space only.

The following expression returns string with tags, where $your_node is a Node object.

InstantXML::KParser->unparseNode($your_node) or simply, unparseNode($your_node)

How to get access to the DOM objects

DOM Level 1 attributes can be accessed by Perl methods which has the same name preceeded by prefix 'get_' or 'set_'.
$your_node->get_nodeName;
$your_node->set_nodeValue("This is a new value.");
DOM Level 1's methods can be called by Perl methods of the same name. Note that many of methods are not implemented.
$your_node->childNodes();
DOM Level 1's null is expressed as Perl "undef" value. So you may need to test some returned values by "defined".

DOM Level 1's wstring is expressed as Perl scalar.

A DOM Level 1's NodeList can be manipulated as a reference of Perl array. But remember that those are out of DOM Level 1. And a NamedNodeMap, a reference of Perl hash.

In case you need some better DOM class implementation(for exaple, Element), I suggest your Element class inherits your Node class (if exists) AND my TmpElement class. You may do this, when you need implementation of exception, or need to correct my bugs on method immediately, etc.

How to create a node

Kit.pm provides a subroutine create_Document_DOMLevel1 , which returns a new Document object. Other objects can be created by methods of Document object.
For more detail, please hack 'Kit.pm'. It's not comlicated. And KParser.pm is a dirty example for it.

Known problems

Memos


Sponsors


Latest version of this document may be found at http://kojun.webalias.com/InstantXML/