XML documents. The tradeoff with such a scheme is that copying
Constructs a SimpleXML instance and parses the given content.
Adds a new element to the root element of the document.
Adds a new element to the root element of the document.
Adds the given attribute to the root element of the document.
Prepend an XML header to the document tree.
Iterates over the children of the root node
Returns the first child element of the root element, which matches the given name.
Finds the first child element of the root element with the given name and sets it's value to the given value. If the element could not be found it's created and the give value is set.
Returns a string representation of the document. It will return the whole tree as a string.
This is a name-value pair representing an attribute
This is a name-value pair representing an element
This struct represents a node in the tree
This is an attribute proxy allowing to perform attribute operations on all the attributes in the root element of this document.
Implements an easy to use interface on top of a DOM Document.
Parse example:
auto doc = new SimpleXML!(char)(content); Stdout(doc).newline;
API example:
auto doc = new SimpleXML!(char); // attach an xml header doc.header; // attach an element with some attributes, plus // a child element with an attached data value doc ~ "element" ~ doc.Attribute("attrib1", "value") ~ doc.Attribute("attrib2") ~ doc.Element("child", "value"); // attach a single child element to the root element // and a single attribute to the root element doc ~= "element2"; doc.attribute ~= "attri3";
X-Path example:
auto doc = new SimpleXML!(char); // attach an xml header doc.header; // attach an element with some attributes, plus // a child element with an attached data value doc ~ "element" ~ doc.Attribute("attrib1", "value") ~ doc.Attribute("attrib2") ~ doc.Element("child", "value"); // select named-element auto set = doc["child"]; // select the first attribute named " // attrib2" in the root element auto att = doc.attribute("attrib2"); // get the value of the first attribute // named attrib1 in the root element char[] value = doc.attribute["attrib1"];
XML documents. The tradeoff with such a scheme is that copying