XMLElement Test5: setAttribute(), getAttributeCount(), hasAttribute()

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;
XMLAttribute atrib;
void setup() {
  size(200, 200);
  xml = new XMLElement(this, "sites.xml");
  xml.setAttribute("width", "100");
  xml.setAttribute("height","100");
  println("adding width and height attribute");
  println("xml.getAttributeCount:" +xml.getAttributeCount());
  xml.setAttribute("height","200");
  println("this element have the attribute width:" +xml.hasAttribute("width"));
  println("this element have the attribute height:" +xml.hasAttribute("height"));
  println("this element have the attribute style:" +xml.hasAttribute("style"));
}