a port of the Processing Visualization Language
Class XMLElement
Name

getIntAttribute()

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.getIntAttribute("id"); 
    String url = kid.getStringAttribute("url"); 
    String site = kid.getContent();
    println(id + " : " + url + " : " + site);    
  }
}
Description Returns an integer attribute of the element. If the default parameter is used and the attribute doesn't exist, the default value is returned. When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned.
Syntax
xml.getIntAttribute(name)

xml.getIntAttribute(name,default)
Parameters
xml any variable of type XMLElement
name String: the name of the attribute
default int: value returned if the attribute is not found
Returns int
Usage Web & Application

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

Creative Commons License
Fork me on GitHub