a port of the Processing Visualization Language
Name

XMLElement

Examples
// The following short XML file called "sites.xml" is parsed 
// in the code below. It must be in the project's "data" directory
// <?xml version="1.0"?>
// <websites>
//   <site id="0" url="processing.org">Processing</site>
//   <site id="1" url="mobile.processing.org">Processing Mobile</site>
// </websites>

XMLElement xml;

void setup() {
  size(200, 200);
  xml = new XMLElement(this, "sites.xml");
  int numSites = xml.getChildCount();
  for (int i = 0; i < numSites; i++) {
    XMLElement kid = xml.getChild(i);
    int id = kid.getInt("id"); 
    String url = kid.getString("url"); 
    String site = kid.getContent();
    println(id + " : " + url + " : " + site);    
  }
}
Description

XMLElement is a representation of an XML object. The object is able to parse XML code. The methods described here are the most basic. More are documented in the Developer's Reference.

The encoding parameter inside XML files is ignored, only UTF-8 (or plain ASCII) are parsed properly.

Methods
getChildCount() Returns the number of children for the element.
getChild() Returns a single child.
getChildren() Returns all of the children as an XMLElement array.
getContent() Returns the content of an element.
getIntAttribute() Returns an integer attribute of the element.
getFloatAttribute() Returns a float attribute of the element.
getStringAttribute() Returns a String attribute of the element.
getName() Returns the name of the element.
Constructor
XMLElement(parent,file)
Parameters
parent PApplet: typically use "this"
file String: name of the XML file to load
Usage Web & Application

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub