XML Data Extracting
in
Programming Questions
•
2 years ago
I'm having some major problems with grabbing data from a very large XML data file. Within the code there are 3000 <Filing> tags. My code successfully pulls the Address attribute from the child tag <Registrant> and outputs the values to a text file. The problem is that the code refuses to cycle through all 3000 filings and only returns 2835 strings. Furthermore when I try to retrieve a different attribute from the xml, such as Amount, the code returns a seemingly arbitrary total of 1995 strings and even stops writing the string mid write. (The value is 40,000 and in the output it is 40).
My code looks like this:
---
XMLElement xml;
String Address;
PrintWriter output;
void setup(){
output = createWriter("addresses.txt");
xml = new XMLElement(this, "2011_1_1_1_fnr.xml");
int numFilings = xml.getChildCount();
String[] addressArray = new String[numFilings];
XMLElement[] children = xml.getChildren("Filing");
XMLElement[] Filing;
//XMLElement Registrant;
for (int i = 0; i < children.length; i++) {
Filing = xml.getChildren("Filing/Registrant");
//Registrant = Filing.getChild("Registrant");
Address = Filing[i].getStringAttribute("Address");
addressArray[i] = Address;
output.println(Address);
}
}
---
Anyone have any ideas? This is stumping me hardcore. I hope Processing just doesn't have limits to its abilities with working with large data sets.
1