This might be a very stupid question, but when I wanted to start using XML in Processing 2.0 I understand that XMLElement got changed to XML class, but how do I make it work??
            
            
I took the old example from XMLElement and tried to adapt it, without luck, what am I missing in the code below?
It gives me a NullPointerException, allthough the XMLfile sites.xml is inside the data folder.
Any ideas? Thanks!
            
            
 
            
           I took the old example from XMLElement and tried to adapt it, without luck, what am I missing in the code below?
It gives me a NullPointerException, allthough the XMLfile sites.xml is inside the data folder.
Any ideas? Thanks!
- // 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>
 XML xml;
 void setup() {
 size(200, 200);
 
 xml = loadXML("sites.xml");
 int numSites = xml.getChildCount();
 for (int i = 0; i < numSites; i++) {
 XML kid = xml.getChild(i);
 int id = kid.getInt("id");
 String url = kid.getString("url");
 String site = kid.getContent();
 println(id + " : " + url + " : " + site);
 }
 }
 
              
              1  
            
 
            
 
 
           
 
             
 
             
 
            