XMLElement Test5: getChildCount(), insertChild(), getContent()
Source
// 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;
XMLElement child;
void setup() {
size(200, 200);
xml = new XMLElement(this, "sites.xml");
child = xml.getChild(0);
int numSites = child.getAttributeCount();
println("Number of first child attributes before remove: " + numSites);
child.removeAttribute("id");
numSites = child.getAttributeCount();
println("Number of first child attributes after remove: " + numSites);
println("Does the 'id' attribute exist?: " +child.hasAttribute("id")); // prints flase;
println("Get url attribute: " +child.getAttribute("url", null, "anna")); // prints processing.org
}