Yage3D.net
 

yage.core.xml

Authors:
Andy Friesen, Eric Poggel

License:
LGPL v3

Xml contains functions and classes for reading, parsing, and writing xml documents.

This hasn't been profiled and probably isn't that efficient.

TODO:
Remove this and replace it with tango's xml

History:
Most of the code in this module originally came from Andy Friesen's Xmld. Xmld was unmaintained, but Andy had placed it in the public domain. This version has been modified to compile under recent versions of dmd and consolidated into a single module.

XmlNode readDocument (Stream src);
Read an entire stream into a tree of XmlNodes.

Example:
 XmlNode xml;
 File file = new File(source, FileMode.In);
 xml = readDocument(file);
 file.close();


class XmlError : object.Exception;
An exception thrown on an xml parsing error.

class XmlNode ;
XmlNode represents a single xml node and has methods for modifying attributes and adding children. All methods that make changes modify this XmlNode rather than making a copy, unless otherwise noted. Many methods return a self reference to allow cascaded calls.

Example:
 // Create an XmlNode tree with attributes and cdata, and write it to a file.
 node.addChild(new XmlNode("mynode").setAttribute("x", 50).
     addChild(new XmlNode("Waldo").addCdata("Hello!"))).write("myfile.xml");


class CData : yage.core.xml.XmlNode;
A specialialized XmlNode for CData .

this();
Construct an empty XmlNode.

this(char[] name);
Construct and set the name of this XmlNode to name.

char[] getName ();
Get the name of this XmlNode.

void setName (char[] newName);
Set the name of this XmlNode.

bool hasAttribute (char[] name);
Does this XmlNode have an attribute with name?

char[] getAttribute (char[] name);
Get the attribute with name, or return null if no attribute has that name.

char[][char[]] getAttributes ();
Return an array of all attributes (by reference, no copy is made).

XmlNode setAttribute (char[] name, char[] value);
Set an attribute to a string value. The attribute is created if it doesn't exist.

XmlNode setAttribute (char[] name, int value);
Set an attribute to an integer value (stored internally as a string). The attribute is created if it doesn't exist.

XmlNode setAttribute (char[] name, float value);
Set an attribute to a flaot value (stored internally as a string). The attribute is created if it doesn't exist.

XmlNode removeAttribute (char[] name);
Remove the attribute with name.

XmlNode addChild (XmlNode newNode);
Add an XmlNode child.

XmlNode[] getChildren ();
Return an array of all child XmlNodes.

XmlNode addCdata (char[] cdata);
Add a child Node of cdata (text).

void read (char[] filename);
Read this XmlNode from a file with filename.

void read (Stream src);
Read this XmlNode from a Stream.

void write (char[] filename);
Write this XmlNode to a file with filename.

void write (Stream dest);
Write this XmlNode and all children to a Stream.

Yage and all source files © 2005-2009 Eric Poggel
Documentation generated with CandyDoc on Sun Sep 20 01:37:10 2009