Getting extra empty childNodes in XML
in
Programming Questions
•
10 months ago
I am pulling an XML feed from the We Feel Fine api. When I try to parse the feed every other childNode is empty.
The XML validates on
W3School's XML validator.
Here's a snippet of what the xml looks like:
-
<?xml version="1.0"?> <feelings> <feeling sentence="i don t feel so high now but it was predictable" feeling="high" born="1992" /> <feeling sentence="i feel good" feeling="good" born="1992" /> <feeling sentence="i rewatch btr it always makes me feel like i m a kat tun fan" born="1992" /> <feeling sentence="i was smiling all weekend had this easing feeling in me and it was just good" feeling="good" born="1992" />
...
<feeling sentence="i think people feel this way some of the time it's just that i feel that way most of the time" born="1981" /> </feelings>
Here's the code I'm using to test the feed.
- void setup() {
- background(255);
- size(100, 100);
- String url = "http://api.wefeelfine.org:8080/ShowFeelings?returnfields=sentence,feeling,gender,born&display=xml&agerange=0,10,20,30,40,50";
- XML xml = loadXML(url);
- for (int i = 0; i<xml.getChildCount(); i++){
- XML childNode = xml.getChild(i);
- println("childNode("+i+") = " + childNode);
- }
- }
- childNode(0) =
- childNode(1) = <feeling born="1992" feeling="high" sentence="i don t feel so high now but it was predictable"/>
- childNode(2) =
- childNode(3) = <feeling born="1992" feeling="good" sentence="i feel good"/>
Thanks,
Stephen
1