XML parsing with XMLElement
in
Programming Questions
•
2 years ago
I'm sure I'm just being dumb here but I can't seem to get XMLElement to do what I want it to (probably because I'm telling it wrong). In
this file, what I want to do is parse out all of the "TrackPoint" data that's buried way down in the structure. Just as a way to tip-toe into this (I'm new to Processing) I thought I'd just use the example on the XMLElement page and then try to slowly expand it until I got to where I wanted. It quickly came to a screeching halt.
First, I did this:
However, all it returns is "Activities", not a list of of the children of Activities. So then I added another level to path: "Activities/Activity" and all it returns is "Activity". Any idea where what I'm doing wrong here? I'm expecting to see all of the children of a node but all I'm seeing is the parent node's name.
Thanks!
Lee
First, I did this:
- XMLElement xml;
void setup() {
size(200, 200);
xml = new XMLElement(this, "2010-01-07-22-52-57.xml");
XMLElement[] kids = xml.getChildren();
for (int i=0; i < kids.length; i++) {
String site = kids[i].getName();
println(site);
}
}
void draw(){
}
- XMLElement xml;
void setup() {
size(200, 200);
xml = new XMLElement(this, "2010-01-07-22-52-57.xml");
XMLElement[] kids = xml.getChildren("Activities");
for (int i=0; i < kids.length; i++) {
String site = kids[i].getName();
println(site);
}
}
void draw(){
}
However, all it returns is "Activities", not a list of of the children of Activities. So then I added another level to path: "Activities/Activity" and all it returns is "Activity". Any idea where what I'm doing wrong here? I'm expecting to see all of the children of a node but all I'm seeing is the parent node's name.
Thanks!
Lee
1