<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with getchildren() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=getchildren%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:54:21 +0000</pubDate>
         <description>Tagged with getchildren() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedgetchildren%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>XML getChildren() every even child is empty</title>
      <link>https://forum.processing.org/two/discussion/27850/xml-getchildren-every-even-child-is-empty</link>
      <pubDate>Wed, 25 Apr 2018 17:07:42 +0000</pubDate>
      <dc:creator>theliquu69</dc:creator>
      <guid isPermaLink="false">27850@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am working with some XML data, and I stumbled upon some rather interesting behavior.</p>

<p>Sketch:</p>

<pre><code>XML xml = loadXML("xml.xml");

printArray(xml.getChildren());
println("-----");

XML[] children = xml.getChildren();

for (int i = 0; i &lt; children.length; i++) {
  println(children[i] + ":");
  XML[] rows = children[i].getChildren();
  for (int r = 0; r &lt; rows.length; r++) {
    println("  row " + r + " '" + rows[r] + "'" +":");
    XML[] cols = rows[r].getChildren();
    for (int c = 0; c &lt; cols.length; c++) {
      println("    col " + c + " '" + cols[c] + "'");
    }
  }
}
</code></pre>

<p>xml.xml:</p>

<pre><code>&lt;?xml version="1.0"?&gt;

&lt;node&gt;
    &lt;table&gt;
        &lt;row&gt;
            &lt;col&gt;1,1&lt;/col&gt;
            &lt;col&gt;1,2&lt;/col&gt;
        &lt;/row&gt;
        &lt;row&gt;
            &lt;col&gt;2,1&lt;/col&gt;
            &lt;col&gt;2,2&lt;/col&gt;
        &lt;/row&gt;
        &lt;row&gt;
            &lt;col&gt;3,1&lt;/col&gt;
            &lt;col&gt;3,2&lt;/col&gt;
        &lt;/row&gt;
    &lt;/table&gt;
&lt;/node&gt;
</code></pre>

<p>Output:</p>

<pre><code>[0] 
[1] &lt;table&gt;&lt;row&gt;&lt;col&gt;1,1&lt;/col&gt;&lt;col&gt;1,2&lt;/col&gt;&lt;/row&gt;&lt;row&gt;&lt;col&gt;2,1&lt;/col&gt;&lt;col&gt;2,2&lt;/col&gt;&lt;/row&gt;&lt;row&gt;&lt;col&gt;3,1&lt;/col&gt;&lt;col&gt;3,2&lt;/col&gt;&lt;/row&gt;&lt;/table&gt;
[2] 
-----
:
&lt;table&gt;&lt;row&gt;&lt;col&gt;1,1&lt;/col&gt;&lt;col&gt;1,2&lt;/col&gt;&lt;/row&gt;&lt;row&gt;&lt;col&gt;2,1&lt;/col&gt;&lt;col&gt;2,2&lt;/col&gt;&lt;/row&gt;&lt;row&gt;&lt;col&gt;3,1&lt;/col&gt;&lt;col&gt;3,2&lt;/col&gt;&lt;/row&gt;&lt;/table&gt;:
  row 0 '':
  row 1 '&lt;row&gt;&lt;col&gt;1,1&lt;/col&gt;&lt;col&gt;1,2&lt;/col&gt;&lt;/row&gt;':
    col 0 ''
    col 1 '&lt;col&gt;1,1&lt;/col&gt;'
    col 2 ''
    col 3 '&lt;col&gt;1,2&lt;/col&gt;'
    col 4 ''
  row 2 '':
  row 3 '&lt;row&gt;&lt;col&gt;2,1&lt;/col&gt;&lt;col&gt;2,2&lt;/col&gt;&lt;/row&gt;':
    col 0 ''
    col 1 '&lt;col&gt;2,1&lt;/col&gt;'
    col 2 ''
    col 3 '&lt;col&gt;2,2&lt;/col&gt;'
    col 4 ''
  row 4 '':
  row 5 '&lt;row&gt;&lt;col&gt;3,1&lt;/col&gt;&lt;col&gt;3,2&lt;/col&gt;&lt;/row&gt;':
    col 0 ''
    col 1 '&lt;col&gt;3,1&lt;/col&gt;'
    col 2 ''
    col 3 '&lt;col&gt;3,2&lt;/col&gt;'
    col 4 ''
  row 6 '':
:
</code></pre>

<p>As you can see, this yields some strange results, where every even array index is empty. This happened to me when I was drawing such a table using index numbers, and totally broke my sketch. What could be causing this?</p>
]]></description>
   </item>
   <item>
      <title>Unfolding Maps: How to map separate lat/long coordinates in an array to screen.</title>
      <link>https://forum.processing.org/two/discussion/27650/unfolding-maps-how-to-map-separate-lat-long-coordinates-in-an-array-to-screen</link>
      <pubDate>Mon, 02 Apr 2018 20:05:49 +0000</pubDate>
      <dc:creator>Neowso</dc:creator>
      <guid isPermaLink="false">27650@/two/discussions</guid>
      <description><![CDATA[<p>I've constructed this code based on the principles of Daniel Schiffmans 'exercise_18_15_new_bubbles_xml.pde' on Github.</p>

<p>All is going well, except that I am having difficulty applying it using Unfolding Maps to display train locations from an XML file.</p>

<p>I wish to display either a 'SimplePointMarker' (from the Unfolding Maps library) or a simple ellipse for each train location. My difficulty is with the mapping. I can map one train with no issues but unsure how to map all within the array.</p>

<p>I have tried a few things like making an array of train locations separately and making another object to handle mapping but both have failed.</p>

<p>The code is posted below. The core issue lies on line 80.</p>

<p>The XML data is contained in this link. I copied it to a static XML file:
<a href="https://data.smartdublin.ie/cgi-bin/rtpi/realtimebusinformation?stopid=7602&amp;format=xml" target="_blank" rel="nofollow">https://data.smartdublin.ie/cgi-bin/rtpi/realtimebusinformation?stopid=7602&amp;format=xml</a></p>

<p>Any help would be greatly appreciated. Thank you :)</p>

<p>*I edited the code to be more simple in my response below</p>
]]></description>
   </item>
   <item>
      <title>XML newbie: how to access 2nd child</title>
      <link>https://forum.processing.org/two/discussion/25792/xml-newbie-how-to-access-2nd-child</link>
      <pubDate>Tue, 02 Jan 2018 22:38:49 +0000</pubDate>
      <dc:creator>kyred</dc:creator>
      <guid isPermaLink="false">25792@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I'd like to parse an XML file with redundant bubbles and I can't figure how to access to content I want.
I don't know how to access the content of the second bubble as in the example below</p>

<p>&lt;?xml version="1.0"?&gt;
// 
//   Goat
//   Leopard
//   Zebra
// </p>

<p>Can someone explains how to, for example get the "Leopard" since we have 3 "animal"?
I tryed things like animal[1] (0 start) or animal[2] or still with some loops but without success</p>

<p>Any help would be appreciated</p>

<p>/-----------
XML xml;</p>

<p>void setup() {
  xml = loadXML("mammals.xml");
  XML firstChild = xml.getChild("animal");
  println(firstChild.getContent());
}</p>

<p>// Sketch prints:
// Goat
//----------</p>
]]></description>
   </item>
   <item>
      <title>Is there a way to check loadXML periodically?</title>
      <link>https://forum.processing.org/two/discussion/22521/is-there-a-way-to-check-loadxml-periodically</link>
      <pubDate>Thu, 11 May 2017 12:08:45 +0000</pubDate>
      <dc:creator>Zelda</dc:creator>
      <guid isPermaLink="false">22521@/two/discussions</guid>
      <description><![CDATA[<p>It seems like you can only define the content from the XML at the certain time in void setup.</p>

<p>I am trying to load headlines from say for example bbc.co.uk. My code loads the XML, and then in void draw, it displays the headline by scrolling from right to left. That works all good.</p>

<p>But if my first paragraph is true, that means that in void draw, it will run out of headlines to print, and it will just repeat the content due to loadXML being load only once. Is that right?</p>

<p>Is there anyway to check it from time to time?</p>

<pre><code>// Example 17-3: Scrolling headlines 

// An array of news headlines
String[] titles; /*= {
  "Processing downloads break downloading record." , //   Multiple Strings are stored in an array.
  "New study shows computer programming lowers cholesterol." ,
};*/
PFont f; // Global font variable
float x; // Horizontal location
int index = 0;

void setup() {
  size(400,200);
  f = createFont( "Arial" ,16,true);
  // Initialize headline offscreen
  x = width;


    String url = "<a href="http://www.worldpress.org/feeds/topstories.xml" target="_blank" rel="nofollow">http://www.worldpress.org/feeds/topstories.xml</a>"; 

  XML rss = loadXML(url);
  // Get title of each element
  XML[] titleXMLElements = rss.getChildren("channel/item/title");
  titles = new String[titleXMLElements.length];
  for (int i = 0; i &lt; titleXMLElements.length; i++) {
    String title = titleXMLElements[i].getContent();
    // Store title in array for later use
    titles[i] = title;
  }
}

void draw() {

  background(255);
  fill (0);
  // Display headline at x location
  textFont(f,16);
  textAlign (LEFT);
  text(titles[index],x, 20); // A specific String from the array is displayed according to the value of the “index” variable.
  // Decrement x
  x = x - 1;
  // If x is less than the negative width,
  // then it is off the screen
  float w = textWidth(titles[index]); // textWidth() is used to calculate the width of the current String.
  if (x &lt; -w) {
    x = width;
    index = (index + 1) % titles.length; // “index"is incremented when the current String has left the screen in order to display a new String.
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Trap for XML Array Out of Bounds exception?</title>
      <link>https://forum.processing.org/two/discussion/22470/trap-for-xml-array-out-of-bounds-exception</link>
      <pubDate>Mon, 08 May 2017 18:50:00 +0000</pubDate>
      <dc:creator>sca610</dc:creator>
      <guid isPermaLink="false">22470@/two/discussions</guid>
      <description><![CDATA[<p>Hi folks -- really simple one here, I think. I’m doing a lookup via the NOAA API for a user-entered ZIP code.</p>

<p>A real ZIP code is fine:
<code><a href="https://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?zipCodeList=90210&amp;product=glance&amp;begin=2004-01-01T00%3A00%3A00&amp;end=2018-12-05T00%3A00%3A00&amp;Unit=e&amp;sky=sky&amp;Submit=Submit" target="_blank" rel="nofollow">https://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?zipCodeList=90210&amp;amp;product=glance&amp;amp;begin=2004-01-01T00:00:00&amp;amp;end=2018-12-05T00:00:00&amp;amp;Unit=e&amp;amp;sky=sky&amp;amp;Submit=Submit</a></code></p>

<p>A bad ZIP code throws an error, obviously:
<code><a href="https://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?zipCodeList=00000&amp;product=glance&amp;begin=2004-01-01T00%3A00%3A00&amp;end=2018-12-05T00%3A00%3A00&amp;Unit=e&amp;sky=sky&amp;Submit=Submit" target="_blank" rel="nofollow">https://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?zipCodeList=00000&amp;amp;product=glance&amp;amp;begin=2004-01-01T00:00:00&amp;amp;end=2018-12-05T00:00:00&amp;amp;Unit=e&amp;amp;sky=sky&amp;amp;Submit=Submit</a></code></p>

<p>What I can’t figure out how to do is trap for that error! I was hoping that try/catch would work...</p>

<p><code>try {
    cloudCover = xml.getChildren("data/parameters/cloud-amount/value");
  }
  catch (Exception e) {
    println(e.getMessage());
    return;
  }</code></p>

<p>...but no luck (it doesn’t println anything) -- even though getChildren works when the ZIP code is valid, and it throws an Array Out of Bounds when passed a bad ZIP code.</p>

<p>Presumably a SOAP error needs to be trapped differently? THANKS!</p>
]]></description>
   </item>
   <item>
      <title>Create a two dimensional array from XML file.</title>
      <link>https://forum.processing.org/two/discussion/20356/create-a-two-dimensional-array-from-xml-file</link>
      <pubDate>Thu, 19 Jan 2017 16:25:19 +0000</pubDate>
      <dc:creator>Alexandros</dc:creator>
      <guid isPermaLink="false">20356@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I have the following XML code:</p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;data type="artists"&gt;
    &lt;artist name="Astroid Power Up"&gt;
        &lt;album&gt;Google Plex&lt;/album&gt;
    &lt;/artist&gt;
    &lt;artist name="Battles"&gt;
        &lt;album&gt;Gloss Drop&lt;/album&gt;
        &lt;album&gt;La Di Da Di&lt;/album&gt;
    &lt;/artist&gt;
    &lt;artist name="Brad Mehldau"&gt;
        &lt;album&gt;Day is Done&lt;/album&gt;
        &lt;album&gt;House on Hill&lt;/album&gt;
        &lt;album&gt;Largo&lt;/album&gt;
        &lt;album&gt;Modern Music&lt;/album&gt;
    &lt;/artist&gt;
    &lt;artist name="Bugge Wesseltoft"&gt;
        &lt;album&gt;Trialogue&lt;/album&gt;
    &lt;/artist&gt;
    &lt;artist name="David Sylvian"&gt;
        &lt;album&gt;Gone to Earth&lt;/album&gt;
    &lt;/artist&gt;
&lt;/data&gt;
</code></pre>

<p>and I want to create an Array of the kind: artist[artistName][albumsByArtist].
For example, 
artist[0][0] = "Battles"
artist[0][1] = "Gloss Drop"
artist[0][2] = "La Di Da Di"
(another more optimal structure suggestion would be welcome)</p>

<p>I made an Array containing the artist name, and for each artist, an Array with each oh his/her albums. I can't find a way to associate the artist with the albums though.</p>

<pre><code>XML data;
String[] artists;

void setup() {
  data = loadXML("data.xml");
  artists = new String[0];

  for (XML artist : data.getChildren("artist")) {
    String n = artist.getString("name");
    artists = append(artists, n); // set name to first element of array

    String[] albumsByArtist = new String[0];

    for (XML album : artist.getChildren("album")) {
      String a = album.getContent();
      albumsByArtist = append(albumsByArtist, a); // fill albumsByArtist with albums names
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Unable to load XML file</title>
      <link>https://forum.processing.org/two/discussion/20149/unable-to-load-xml-file</link>
      <pubDate>Sun, 08 Jan 2017 12:26:30 +0000</pubDate>
      <dc:creator>CharlesDesign</dc:creator>
      <guid isPermaLink="false">20149@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I'm trying to allow the user the enter a postcode and then retrieve the list of properties in the area with the Zoopla api.
Unfortunately, I get the following error on line 51 and 59, any ideas?</p>

<p><code>TypeError: xml is undefined[Learn More]</code></p>

<p>It's working fine in Processing.</p>

<p>Thanks in advance, 
Charles</p>

<pre><code>var xml, postInput, postButton, myDiv, cnv, postCode;
var running;

function setup() {

    running = false;

    cnv = createCanvas(windowWidth * 0.1, windowHeight / 2);
    var y = (windowHeight / 2) - 25;
    cnv.position(10, y);
    cnv.style("z-index", "-1")
    textAlign(CENTER);
    textSize(16);

    myDiv = createDiv("Property Analyser");
    myDiv.position((windowWidth / 2) - 100, windowHeight * 0.40);
    myDiv.style("font-size", "24px");
    myDiv.style("color", "#FFFFFF");
    myDiv.style("z-index", "2")

    postInput = createInput();
    postInput.position(windowWidth * 0.5 - (windowWidth * 0.1), windowHeight * 0.5);
    postInput.style("z-index", "2")
    postInput.size(windowWidth * 0.2, windowHeight * 0.05);

    postButton = createButton('Input Postcode');
    postButton.size(windowWidth * 0.1, windowHeight * 0.04);
    postButton.position(windowWidth * 0.5 - windowWidth * 0.05, windowHeight * 0.57);
    postButton.mousePressed(next);
    postButton.style("z-index", "2")

}

function draw() {

    if (running) {
        background(255);
    }
}

function next() {
    postCode = postInput.value();
    postButton.style("visibility", "hidden");
    postInput.style("visibility", "hidden");
    myDiv.style("z-index", "-1");
    cnv.style("z-index", "1")
    running = true;

    console.log(postCode);
    var url = "<a href="http://api.zoopla.co.uk/api/v1/property_listings.xml?postcode=" target="_blank" rel="nofollow">http://api.zoopla.co.uk/api/v1/property_listings.xml?postcode=</a>" + postCode + "&amp;api_key=bmm77zppverakbnfnmtyuky3";
    xml = loadXML(url, printHouses(), message());
}

function message(message){
    console.log(message);
}

function printHouses(){
    var listings = xml.getChildren("listing");

    for (var i = 0; i &lt; listings.length; i++) {
        var listing = listings[i].getChild("agent_address");
            console.log(listing.getContent());
    }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>The length of the string returned from getContent()</title>
      <link>https://forum.processing.org/two/discussion/20034/the-length-of-the-string-returned-from-getcontent</link>
      <pubDate>Mon, 02 Jan 2017 12:07:11 +0000</pubDate>
      <dc:creator>bolodragon</dc:creator>
      <guid isPermaLink="false">20034@/two/discussions</guid>
      <description><![CDATA[<p>Hi, 
When I try to see the length of the content of a certain child in XML data, I found out it is always 3 more than it should be. Is that normal?
For example,
in the xml userData:</p>

<p><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;userData&gt;
     &lt;user&gt;u2017121229&lt;/user&gt;
     &lt;user&gt;u2017121230&lt;/user&gt;
     &lt;user&gt;u2017121230&lt;/user&gt;
     &lt;user&gt;u201712123055&lt;/user&gt;
&lt;/userData&gt;</code>
when I use getContent to get "u2017121230", it actually gives me a String of the size 14, instead of 11</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>Get stroke color of svg drawing</title>
      <link>https://forum.processing.org/two/discussion/18979/get-stroke-color-of-svg-drawing</link>
      <pubDate>Fri, 11 Nov 2016 02:42:35 +0000</pubDate>
      <dc:creator>royal_orchestra</dc:creator>
      <guid isPermaLink="false">18979@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I'm trying to animate a line drawing. 
This article helped me to do it:
<a href="https://forum.processing.org/one/topic/make-a-dot-follow-a-svg-path.html" target="_blank" rel="nofollow">https://forum.processing.org/one/topic/make-a-dot-follow-a-svg-path.html</a>
But - I have an SVG with strokes in different colors. How can I read it so the  slowly painted image looks like the sourcefile in the end? (The draw order or z-index is also interesting. )
I could not find any explanation how to get and use the stroke-color with geomerative anywhere.
Best regards
Jens</p>
]]></description>
   </item>
   <item>
      <title>Simple XML to JSON converter script</title>
      <link>https://forum.processing.org/two/discussion/18667/simple-xml-to-json-converter-script</link>
      <pubDate>Sun, 23 Oct 2016 11:04:44 +0000</pubDate>
      <dc:creator>setup</dc:creator>
      <guid isPermaLink="false">18667@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'd thought this may be a quick program to write in processing, but I'm stuck on the basics.  I'm attempting to convert a simply structured XML file into JSON, but I cannot get the syntax to work.</p>

<p>My XML file structure looks as follows:</p>

<pre><code>&lt;?xml version="1.0" encoding="windows-1252" ?&gt;
&lt;TABLE&gt;
   &lt;DD&gt;
      &lt;ID&gt; AB-1234567 &lt;/ID&gt;
      &lt;DOMAIN&gt; DD &lt;/DOMAIN&gt;
      &lt;USUB&gt; AB-0000000-0000001 &lt;/USUB&gt;
      &lt;DDSEQ&gt; 1 &lt;/DDSEQ&gt;
      &lt;DDDTC missing=" " /&gt;
      &lt;DDDY missing="." /&gt;
   &lt;/DD&gt;
   &lt;DD&gt;
      &lt;ID&gt; AC-1234567 &lt;/ID&gt;
      &lt;DOMAIN&gt; DD &lt;/DOMAIN&gt;
      &lt;USUB&gt; AB-0000000-00000002 &lt;/USUB&gt;
      &lt;DDSEQ&gt; 1 &lt;/DDSEQ&gt;
      &lt;DDDTC&gt; 2015-06-03 &lt;/DDDTC&gt;
      &lt;DDDY&gt; -1 &lt;/DDDY&gt;
   &lt;/DD&gt;
&lt;/TABLE&gt;
</code></pre>

<p>and I'd like a JSON that looks like the following (taking into account the text and numerics and respective missing values):</p>

<pre><code>[  
   {
    "ID": "AB-1234567",
    "DOMAIN": "DD",
    "USUB": "AB-0000000-0000001",
    "DDSEQ": 1,
    "DDDTC": "",
    "DDDY": .,
  },
  {
    "ID": "AB-1234567",
    "DOMAIN": "DD",
    "USUB": "AB-0000000-0000002",
    "DDSEQ": 1,
    "DDDTC": "2015-06-03",
    "DDDY": -1,
  }
]
</code></pre>

<p>My fairly poor programming attempt so far is as follows:</p>

<pre><code>XML xml;

void setup() {
  xml = loadXML("dd.xml");
  XML[] children = xml.getChildren("DD");
  println(xml.getName());
  for (int i = 0; i &lt; children.length; i++) {
    println(i + " "+ children[i].getChild(i) + " "+ children[i].getName());
  }
}
</code></pre>

<p>I don't get what I expected when I list the children as I would have expected 6 children, but I only get 1.</p>

<p>Can anyone point me in the right direction?</p>

<p>Many thanks</p>
]]></description>
   </item>
   <item>
      <title>Can't get data from Yahoo weather.</title>
      <link>https://forum.processing.org/two/discussion/18009/can-t-get-data-from-yahoo-weather</link>
      <pubDate>Mon, 29 Aug 2016 19:30:33 +0000</pubDate>
      <dc:creator>charleswho</dc:creator>
      <guid isPermaLink="false">18009@/two/discussions</guid>
      <description><![CDATA[<p>I wanna get 7-day weather forcast data from Yahoo weather. I tried a thousand times but it simply does' t work. I cannot even make it with the following code. Could somebody help me with that? I appreciate it so much. I am using Processing 3.2.1 and windows 10.</p>

<pre><code>                void setup(){
                  XML xml = loadXML("https:"+"//query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%3D4177");

                 XML yweather = xml.getChild("channel/item/yweather:condition");

                  int weatherCondition = yweather.getInt("code");

                  // Print the results
                  println(weatherCondition);

                }
</code></pre>

<p>I tried example code from processing.org and it did work.</p>

<pre><code>                // The following short XML file called "mammals.xml" is parsed 
                // in the code below. It must be in the project's "data" folder.
                //
                // &lt;?xml version="1.0"?&gt;
                // &lt;mammals&gt;
                //   &lt;animal id="0" species="Capra hircus"&gt;Goat&lt;/animal&gt;
                //   &lt;animal id="1" species="Panthera pardus"&gt;Leopard&lt;/animal&gt;
                //   &lt;animal id="2" species="Equus zebra"&gt;Zebra&lt;/animal&gt;
                // &lt;/mammals&gt;

                XML xml;

                void setup() {
                  xml = loadXML("mammals.xml");
                  XML[] children = xml.getChildren("animal");

                  for (int i = 0; i &lt; children.length; i++) {
                    int id = children[i].getInt("id");
                    String coloring = children[i].getString("species");
                    String name = children[i].getContent();
                    println(id + ", " + coloring + ", " + name);
                  }
                }

                // Sketch prints:
                // 0, Capra hircus, Goat
                // 1, Panthera pardus, Leopard
                // 2, Equus zebra, Zebra
</code></pre>

<p>And then I saved the weather data as xml file and load it in Processing. It still says Null Pointer Exception. Also I tried Yahoo Weather Library from com.onformative.yahooweather. But it doen' t have 7-day forcast. Thanks for your help!</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/354/DUS32NCRJBW3.JPG" alt="捕获" title="捕获" /></p>
]]></description>
   </item>
   <item>
      <title>Why won't my if satements work with my XML data?</title>
      <link>https://forum.processing.org/two/discussion/17907/why-won-t-my-if-satements-work-with-my-xml-data</link>
      <pubDate>Fri, 19 Aug 2016 14:54:23 +0000</pubDate>
      <dc:creator>PoisonousLynn</dc:creator>
      <guid isPermaLink="false">17907@/two/discussions</guid>
      <description><![CDATA[<p><strong>Everytime I try to run the following, it tells me "_Answer" not recognised. Please help me.</strong></p>

<pre><code>XML lynnsXmlfile;
float x = 10;
int y= 0;

//int ySpace = 20;


void setup(){
  size(800,600);
  background(255);
  smooth();


  lynnsXmlfile = loadXML("surveys.xml");
  //println(lynnsXmlfile);

  float placement = width*5;
  float MaleX = placement;
  float MaleY = 300;
  float FemX = placement*20;
  float FemY = 300;
  float North_JohannesburgX = placement*30;
  float North_JohannesburgY = 300;
  float West_JohannesburgX = placement*40;
  float West_JohannesburgY = 300;
  float East_JohannesburgX = placement*50;
  float East_JohannesburgY = 300;
  float South_JohannesburgX = placement*60;
  float South_JohannesburgY = 300;
  float WhiteX = placement*70;
  float WhiteY = 300;
  float BlackX = placement*80;
  float BlackY = 300;
  float IndianX = placement*90;
  float IndianY = 300;





    XML [] surveys = lynnsXmlfile.getChildren("record");
    XML [] genderQuestions = lynnsXmlfile.getChildren("record/gender");
    XML [] raceQuestions = lynnsXmlfile.getChildren("record/race");
    XML [] locationQuestions = lynnsXmlfile.getChildren("record/location");
    XML [] area_ratingQuestions = lynnsXmlfile.getChildren("record/area_rating");
    XML [] frequency_eatQuestions = lynnsXmlfile.getChildren("record/frequency_eat");
    XML [] frequency_mealsQuestions = lynnsXmlfile.getChildren("record/frequency_meals");
    XML [] frequency_mostQuestions = lynnsXmlfile.getChildren("record/frequency_most");
    XML [] frequency_bestQuestions = lynnsXmlfile.getChildren("record/frequency_best");
  //XML [] survey = lynnsXmlfile.getContent("data-set/location");


  //printArray(surveys);

  for(int i=0; i&lt;=surveys.length-1; i++){
  String genderAnswer = genderQuestions[i].getContent();
  println("gender "+i+": "+genderAnswer);
  String raceAnswer = raceQuestions[i].getContent();
 println("race "+i+": "+raceAnswer);
  String locationAnswer = locationQuestions[i].getContent();
  //println("location "+i+": "+locationAnswer);
  String frequency_eatAnswer = frequency_eatQuestions[i].getContent();
  //println("frequency eat "+i+": "+frequency_eatAnswer);
 String frequency_mealsAnswer = frequency_mealsQuestions[i].getContent();
 String frequency_mostAnswer = frequency_mostQuestions[i].getContent();
 String frequency_bestAnswer = frequency_bestQuestions[i].getContent();
 String area_ratingAnswer = area_ratingQuestions[i].getContent();
  }



   fill(100,255,255);
   //println(genderX);
   ellipse(MaleX, MaleY, 40,40);
   ellipse(FemX, FemY, 40,40);
   ellipse(North_JohannesburgX, North_JohannesburgY, 40,40);
   ellipse(West_JohannesburgX, West_JohannesburgY, 40,40);
   ellipse(East_JohannesburgX, East_JohannesburgY, 40,40);
   ellipse(South_JohannesburgX, South_JohannesburgY, 40,40);
   ellipse(WhiteX, WhiteY, 40,40);
   ellipse(BlackX, BlackY, 40,40);
   ellipse(IndianX, IndianY, 40,40);


   if (genderAnswer.indexOf("Fem") != -1){
    fill(125,255,255); 
     noStroke();
   }

      if (genderAnswer.indexOf("Male") != -1){
    fill(255,255,125); 
     noStroke();
   }

    if (locationAnswer.indexOf("North_Johannesburg") != -1){
    fill(125,255,255); 
     noStroke();
   }else{
     fill(255,255,125); 
     noStroke();
   }

    if (raceAnswer.indexOf("White") != -1){
    fill(250,255,250);
     noStroke();
   }else{
     fill(255,255,215);
     noStroke();
   }


    if (frequency_bestAnswer.indexOf("North_Johannesburg") != -1){
    fill(125,0,0); 
     noStroke();
   }else{
     fill(5,5,125); 
     noStroke();
   }




    fill(30);
   noStroke();
   rect(0,500,800,100);
}

&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
&lt;data-set xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank" rel="nofollow">http://www.w3.org/2001/XMLSchema-instance</a>"&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;Indian&lt;/race&gt;
        &lt;location&gt;South_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Non-binary&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;East_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;East_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;5&lt;/rating&gt;
        &lt;eat&gt;Three or four&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;Three or four&lt;/eat&gt;
        &lt;meals&gt;Lunch&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Lunch&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;1&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;One or more&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;One or more&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;1&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;5&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Breakfast&lt;/meals&gt;
        &lt;most&gt;East_Johannesburg&lt;/most&gt;
        &lt;best&gt;East_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Lunch&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;West_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Breakfast&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;West_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;South_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;One or more&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Breakfast&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;5&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;Pretoria east&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Lunch&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Lunch&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;West_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;Three or four&lt;/eat&gt;
        &lt;meals&gt;Lunch&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;One or more&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;East_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Lunch&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;West_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;Three or four&lt;/eat&gt;
        &lt;meals&gt;One or more&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;West_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Male&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;Centurion&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;One or more&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;3&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;North_Johannesburg&lt;/location&gt;
        &lt;rating&gt;4&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;Dinner&lt;/meals&gt;
        &lt;most&gt;North_Johannesburg&lt;/most&gt;
        &lt;best&gt;North_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
    &lt;record&gt;
        &lt;gender&gt;Fem&lt;/gender&gt;
        &lt;race&gt;White&lt;/race&gt;
        &lt;location&gt;West_Johannesburg&lt;/location&gt;
        &lt;rating&gt;5&lt;/rating&gt;
        &lt;eat&gt;One or two&lt;/eat&gt;
        &lt;meals&gt;One or more&lt;/meals&gt;
        &lt;most&gt;West_Johannesburg&lt;/most&gt;
        &lt;best&gt;West_Johannesburg&lt;/best&gt;
    &lt;/record&gt;
&lt;/data-set&gt;
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to read deeper into XML</title>
      <link>https://forum.processing.org/two/discussion/17692/how-to-read-deeper-into-xml</link>
      <pubDate>Fri, 29 Jul 2016 08:27:32 +0000</pubDate>
      <dc:creator>JamesS</dc:creator>
      <guid isPermaLink="false">17692@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I've been able to follow examples of the loadXML example on this page <a rel="nofollow" href="https://processing.org/reference/XML.html">https://processing.org/reference/XML.html</a> successfully, but I am trying to work with an XML file from wunderground.com weather API that looks like this:</p>

<p><a rel="nofollow" href="http://api.wunderground.com/api/5a7d1edd0fd022d0/forecast/q/TN/gatlinburg.xml">api.wunderground.com/api/5a7d1edd0fd022d0/forecast/q/TN/gatlinburg.xml</a></p>

<p>Out of this whole thing, I was hoping to just isolate a few elements like HIGH and LOW temperatures and storm warnings. I just can't figure out how to jump to those tags.</p>

<p>Using a different XML from the same API I was able to do what I want with the following code, but the above code has more "Layers".</p>

<p>This is pretty much what I was trying to do:</p>

<pre><code>                    XML xmlFeed = loadXML("weather.xml");

                    int numSites = xmlFeed.getChildCount();     
                    //println(numSites);
                    for (int i = 0; i &lt; numSites; i++) {   
                      XML tag = xmlFeed.getChild(i);
                      if (tag.getName().equals("temperature_string")) {
                        String temperature_string = tag.getContent();
                        println("temperature_string: " + temperature_string);
                      } else if (tag.getName().equals("dewpoint_f")) {
                        String dewpoint_f = tag.getContent();
                        println("dewpoint_f: " + dewpoint_f);
                      }
                    }
                    exit();
</code></pre>

<p>I very much appreciate any help anyone is able to give.</p>
]]></description>
   </item>
   <item>
      <title>Drawing music waves from XML File</title>
      <link>https://forum.processing.org/two/discussion/16581/drawing-music-waves-from-xml-file</link>
      <pubDate>Fri, 13 May 2016 10:03:36 +0000</pubDate>
      <dc:creator>Sarah</dc:creator>
      <guid isPermaLink="false">16581@/two/discussions</guid>
      <description><![CDATA[<p>Hello, 
I draw Lines of notes from an XML file. But the lines are not correct!?</p>

<p>Why they draw up and down? They would be more represented in waveform?</p>

<p>You can see 2 images: The notes in orange and the reaction with Processing.</p>

<p>Here the code:</p>

<p>**The code: **</p>

<pre><code>XML xml;
int stepWert = 10;
float summe;
String stepNote;
String octaveWert;
String durationWert;
String instrumentWert;
String c = "C";
String d = "D";
String e = "E";
String f = "F";
String g = "G";
String a = "A";
String h = "H";
String b = "B";
float x = 0;

import processing.pdf.*;

void setup() {
  beginRecord (PDF, "vektoren.pdf");
  size (80500, 700);
  background (0);
  noFill();
  stroke(250, 187, 0);
  strokeWeight(1);

  //Laden des XML Dokuments
  xml = loadXML("score-partwise.xml");

  //Filtern der für den Sketch wichtigen Daten
  // aus dem geladenen XML Dokument
  XML[] instrument = xml.getChildren("part");
  XML[] step = xml.getChildren("part/measure/note/pitch/step");
  XML[] octave = xml.getChildren("part/measure/note/pitch/octave");
  XML[] duration = xml.getChildren("part/measure/note/duration");

  for (int n = 0; n &lt; 1; n++) {
    instrumentWert = instrument[n].getString("id");
  }

  //für jeden Datensatz im XML Dokument
beginShape();
for (int n = 0; n &lt; step.length; n++) {
  stepNote = step[n].getContent();
    curveVertex (x, height-summe);
    stepNote = step[n].getContent ();
    octaveWert = octave[n].getContent ();
    durationWert = duration[n].getContent ();
    println ("step" + stepNote + "octave" + octaveWert + "duration" + durationWert 
    + "instrument" + instrumentWert);

    if (stepNote.equals(c)) stepWert = 1;
    if (stepNote.equals(d)) stepWert = 2;
    if (stepNote.equals(e)) stepWert = 3;
    if (stepNote.equals(f)) stepWert = 4;
    if (stepNote.equals(g)) stepWert = 5;
    if (stepNote.equals(a)) stepWert = 6;
    if (stepNote.equals(h)) stepWert = 7;
    if (stepNote.equals(b)) stepWert = 8;

    println ("stepWert" + stepWert);

    summe = stepWert*40 + int(octaveWert)*40;
    println ("Summe" + summe);

    x+=7;
}
endShape();
endRecord();   
}
</code></pre>

<hr />

<p><img src="https://forum.processing.org/two/uploads/imageupload/235/P1L2SXBCW6M4.png" alt="01_Anfang_Klarinette" title="01_Anfang_Klarinette" /></p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/223/TQJUUGWLERDQ.png" alt="01_Anfang_Klarinette_processing" title="01_Anfang_Klarinette_processing" /></p>
]]></description>
   </item>
   <item>
      <title>How to pull hex color infomation from and XML file</title>
      <link>https://forum.processing.org/two/discussion/15941/how-to-pull-hex-color-infomation-from-and-xml-file</link>
      <pubDate>Sat, 09 Apr 2016 23:55:22 +0000</pubDate>
      <dc:creator>sammialyssa</dc:creator>
      <guid isPermaLink="false">15941@/two/discussions</guid>
      <description><![CDATA[<p>Newbie here... I have hex color information in an XML file and want to fill my rectangles with the colors from the XML file. Can someone explain to me how I can accomplish this?</p>
]]></description>
   </item>
   <item>
      <title>Loading in points from XML</title>
      <link>https://forum.processing.org/two/discussion/14891/loading-in-points-from-xml</link>
      <pubDate>Sat, 13 Feb 2016 15:09:55 +0000</pubDate>
      <dc:creator>elliot</dc:creator>
      <guid isPermaLink="false">14891@/two/discussions</guid>
      <description><![CDATA[<p>I'm doing a little text to load in some points from an xml file and loading them into an arrayList to display them on screen as ellipses. I've got some code now but when I run it I only get one ellipse drawn at 0,0 even though that isn't one of the points that I'm trying to load in.</p>

<p>Here is my code with my class Points</p>

<pre><code>class Points {
  float xPos, yPos;

  Points(float _xPos, float _yPos) {

    xPos = _xPos;
    yPos = _yPos;
  }
}

XML xml;
ArrayList&lt;Points&gt; point = new ArrayList&lt;Points&gt;();

void setup() {
  size(640, 360);
  background(255);
  //point = new Points(-10, -10);
  //loadData();

  xml = loadXML("newPointList.xml");
  XML[] children = xml.getChildren("points");

  //point = new Points[children.length];

  for (int i = 0; i &lt; children.length; i ++) {

    XML xVal = children[i].getChild("x");
    float x = xVal.getInt ("x");

    XML yVal = children[i].getChild("y");
    float y = xVal.getInt ("y");

    Points addingData = new Points(x, y);
    println("x " + x + ", " + "y " + y);
    point.add(addingData);
  }
}

void draw() {

  for (int i = 0; i&lt; point.size(); i++) {

    Points drawPoints = point.get(i);
    ellipse(drawPoints.xPos, drawPoints.yPos, 10, 10);
  }
}
</code></pre>

<p>Here is the basic XML of points I'm trying to use called newPointList.xml</p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;pointList&gt;
&lt;points&gt;
&lt;x&gt;30&lt;/x&gt;
&lt;y&gt;20&lt;/y&gt;
&lt;/points&gt;
&lt;points&gt;
&lt;x&gt;85&lt;/x&gt;
&lt;y&gt;20&lt;/y&gt;
&lt;/points&gt;
&lt;points&gt;
&lt;x&gt;85&lt;/x&gt;
&lt;y&gt;75&lt;/y&gt;
&lt;/points&gt;
&lt;/pointList&gt;
</code></pre>

<p>Feel like the process is right, but still only has a point as zero. Any help would be appreciated.
Thanks</p>
]]></description>
   </item>
   <item>
      <title>[Fatal Error] :1:1: Premature end of file.</title>
      <link>https://forum.processing.org/two/discussion/11671/fatal-error-1-1-premature-end-of-file</link>
      <pubDate>Mon, 13 Jul 2015 16:05:22 +0000</pubDate>
      <dc:creator>henklamers</dc:creator>
      <guid isPermaLink="false">11671@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I am working on the last chapter of the Generative Design book entering M_6_2_01.
Anyone knows how to solve this problem? When I run it I get this message in my console:</p>

<pre><code>[Fatal Error] :1:1: Premature end of file.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
    at processing.data.XML.&lt;init&gt;(XML.java:187)
    at processing.core.PApplet.loadXML(PApplet.java:6189)
    at processing.core.PApplet.loadXML(PApplet.java:6179)
    at M_6_2_01.setup(M_6_2_01.java:49)
    at processing.core.PApplet.handleDraw(PApplet.java:2281)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:237)
    at processing.core.PApplet.run(PApplet.java:2177)
    at java.lang.Thread.run(Thread.java:744)
java.lang.NullPointerException
</code></pre>

<p>Here is the Generative Design book code:</p>

<pre><code>// M_6_2_01.pde
// 
// Generative Gestaltung, ISBN: 978-3-87439-759-9
// First Edition, Hermann Schmidt, Mainz, 2009
// Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
// Copyright 2009 Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
//
// http: //www.generative-gestaltung.de
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http: //www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * loads the name of the links on the wikipedia-site "Superegg"
 * and prints them to the console
 */

XML myXML;
XML[] links;
String query;

void setup() {
  query = "http:" + "//en.wikipedia.org/w/api.php?titles=Superegg&amp;format=xml&amp;action=query&amp;prop=links&amp;pllimit=500";

  try {
    myXML = loadXML(query);
    links = myXML.getChildren("query/pages/page/links/pl"); 

    for (int i = 0; i &lt; links.length; i++) {
      String title = links[i].getString("title");
      println("Link " + i + ": " + title);
    }
  } 
  catch (Exception exception) {
    println(exception);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>loading xml</title>
      <link>https://forum.processing.org/two/discussion/13332/loading-xml</link>
      <pubDate>Sat, 31 Oct 2015 20:18:07 +0000</pubDate>
      <dc:creator>honzojd</dc:creator>
      <guid isPermaLink="false">13332@/two/discussions</guid>
      <description><![CDATA[<p>Hello I've one xml on the internet. there are are many values with the same ID. I mean there's an XXX child, well I can display the first child, but how to display the second? or all values with a child XXX? Could you please help me? thanks guys!</p>
]]></description>
   </item>
   <item>
      <title>Write in File XML</title>
      <link>https://forum.processing.org/two/discussion/12317/write-in-file-xml</link>
      <pubDate>Mon, 31 Aug 2015 13:51:25 +0000</pubDate>
      <dc:creator>Jose_Aparecido</dc:creator>
      <guid isPermaLink="false">12317@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,</p>

<p>I am researching how to service XML file, so far managed to read a file generated, but I'm having trouble adding a record in an existing file, and also delete a specific item.</p>

<p>I'm looking for example ( addChild() ):</p>

<p><a href="https://processing.org/reference/XML_addChild_.html" target="_blank" rel="nofollow">https://processing.org/reference/XML_addChild_.html</a></p>

<p>[code below]</p>

<p>As it would be to add another item? For example:
Lions</p>

<p>One more thing, as I would to delete a specific item?</p>

<p>For example, to remove:
Zebra</p>

<p>I hope you understood any help, I thank you.</p>
]]></description>
   </item>
   <item>
      <title>I am trying to read a certain value in an XML file, I but fail and fail again</title>
      <link>https://forum.processing.org/two/discussion/11704/i-am-trying-to-read-a-certain-value-in-an-xml-file-i-but-fail-and-fail-again</link>
      <pubDate>Wed, 15 Jul 2015 12:39:17 +0000</pubDate>
      <dc:creator>Magnetic_Garden</dc:creator>
      <guid isPermaLink="false">11704@/two/discussions</guid>
      <description><![CDATA[<p>This is the code from were I start;</p>

<pre><code>XML xml;

void setup() {
  xml = loadXML("mammals.xml");
  XML[] children = xml.getChildren("animal");

  for (int i = 0; i &lt; children.length; i++) {
    int id = children[i].getInt("id");
    String coloring = children[i].getString("species");
    String name = children[i].getContent();
    println(id + ", " + coloring + ", " + name);
  }
}
</code></pre>

<p>but none of my adaptions give me access to the "test" element.
I tried syntax like this;</p>

<pre><code>    for( int j = 0 ; j &lt; 10 ; j++ ){
    XML[] nameHelper = children[j].getChildren("description");
    }
</code></pre>

<p>but this gives me some weird hex-like values
when I try nameHelper[0], I get a null.
when I try nameHelper[1], I get a null pointer exeception.</p>

<p>sorry if I am not clear in my explanation.</p>

<p>here are the screenshots from the xlm.
<img src="http://forum.processing.org/two/uploads/imageupload/693/QH3811L5D4C0.png" alt="SCREEN" title="SCREEN" />
<img src="http://forum.processing.org/two/uploads/imageupload/521/1GWZGRJM8371.png" alt="SCREEN-2" title="SCREEN-2" /></p>
]]></description>
   </item>
   <item>
      <title>Access specific data in a complex XML file</title>
      <link>https://forum.processing.org/two/discussion/10792/access-specific-data-in-a-complex-xml-file</link>
      <pubDate>Wed, 13 May 2015 14:26:05 +0000</pubDate>
      <dc:creator>fedpep</dc:creator>
      <guid isPermaLink="false">10792@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I'm loading XML data from an API and this is a simplified versione of the structure of the XML:</p>

<p>I need to access the parameter "name" inside CreditArtist. I tried with all the combination of getChildren and getChild (following the examples in the reference) but I couldn't wrap my head around this and couldn't access that data.</p>

<p><code>&lt;Credits xmlns="*********" xmlns:i="<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank" rel="nofollow">http://www.w3.org/2001/XMLSchema-instance</a>"&gt;
    &lt;status&gt;ok&lt;/status&gt;
    &lt;code&gt;200&lt;/code&gt;
    &lt;parameters&gt;
        &lt;apiKey&gt;*********&lt;/apiKey&gt;
        &lt;id&gt;*********&lt;/id&gt;
        &lt;format&gt;xml&lt;/format&gt;
    &lt;/parameters&gt;
    &lt;view&gt;
        &lt;total&gt;*********&lt;/total&gt;
    &lt;/view&gt;
    &lt;credits&gt;
        &lt;NMCredit&gt;
            &lt;id&gt;*********&lt;/id&gt;
            &lt;title&gt;*********&lt;/title&gt;
            &lt;primaryartists&gt;
                &lt;CreditArtist&gt;
                    &lt;id&gt;*********&lt;/id&gt;
                    &lt;name&gt;*********&lt;/name&gt;
                &lt;/CreditArtist&gt;
            &lt;/primaryartists&gt;
            &lt;year&gt;*********&lt;/year&gt;
            &lt;credit&gt;*********&lt;/credit&gt;
            &lt;type&gt;*********&lt;/type&gt;
        &lt;/NMCredit&gt;
        &lt;NMCredit&gt;
            &lt;id&gt;*********&lt;/id&gt;
            &lt;title&gt;*********&lt;/title&gt;
            &lt;primaryartists&gt;
                &lt;CreditArtist&gt;
                    &lt;id&gt;*********&lt;/id&gt;
                    &lt;name&gt;*********&lt;/name&gt;
                &lt;/CreditArtist&gt;
            &lt;/primaryartists&gt;
            &lt;year&gt;*********&lt;/year&gt;
            &lt;credit&gt;*********&lt;/credit&gt;
            &lt;type&gt;*********&lt;/type&gt;
        &lt;/NMCredit&gt;
    &lt;/credits&gt;
&lt;/Credits&gt;</code></p>
]]></description>
   </item>
   <item>
      <title>External data into Processing</title>
      <link>https://forum.processing.org/two/discussion/10594/external-data-into-processing</link>
      <pubDate>Thu, 30 Apr 2015 11:51:06 +0000</pubDate>
      <dc:creator>ClausNeergaard</dc:creator>
      <guid isPermaLink="false">10594@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys,</p>

<p>I am fairly new to this external-data-into-Processing stuff, so I am wondering what I am doing wrong with this tiny piece of code ...</p>

<pre><code>XML root               = loadXML("<a href="http://www.w3schools.com/xml/cd_catalog.xml" target="_blank" rel="nofollow">http://www.w3schools.com/xml/cd_catalog.xml</a>");
XML[] year             = root.getChildren("CATALOG/CD/YEAR");

for (int i = 0; i &lt; year.length; i++) {
  println(year[i]);
}
</code></pre>

<p>Thanks in advance!</p>
]]></description>
   </item>
   </channel>
</rss>