<?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 loadxml() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=loadxml%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:54:14 +0000</pubDate>
         <description>Tagged with loadxml() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedloadxml%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How do I cleanly catch Exceptions?</title>
      <link>https://forum.processing.org/two/discussion/27999/how-do-i-cleanly-catch-exceptions</link>
      <pubDate>Sun, 20 May 2018 20:08:21 +0000</pubDate>
      <dc:creator>GLV</dc:creator>
      <guid isPermaLink="false">27999@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I get a "java.net.UnknownHostException" in the example I provided if there is no network connection.
In my full blown code I get a "NullPointerException" also displayed in the bar above console.</p>

<p>You have to disable network to see the error! 
The code works if there is a network connection and URL is correct and available and displays retrieved data in console.</p>

<p>If you click on sketch window it will loop() and you will try to access the url.
I did this so you do not keep retrieving data in an endless loop!</p>

<p>My code works for what I am doing.</p>

<p>Is there a better way to catch an Exception such as this? And not fill console with an error message.</p>

<pre><code>String text = "";
String url = null;

// Added missing code that was in a tab
XML xml;
boolean testNull = false;

public void setup() 
  {
  size(200, 200);     
  }

public void draw() 
  {
  url = "http://" + "www.yr.no/place/Ecuador/Galapagos/Seymour/forecast.xml";
  loadxml();
  noLoop();
  }

void mousePressed() 
  {
  loop();
  }

void loadxml()
  {
  try
    {
    xml = loadXML(url);
    }
  catch (NullPointerException nullPointer)
    {
    testNull = true;
    }   

    println(testNull);

  if (testNull == false)
    {  
  // Load the XML document
    xml = loadXML(url);  

    XML credit = xml.getChild("credit/link");
    println(credit.getString("text"));
    text = credit.getString("text");
    println(credit.getString("url"));
    url = credit.getString("url");  
    }
  else
    {
    text = ("Unavailable"); 
    url = ("Unavailable");
    println(text);
    println(url);
    }  
  }  
</code></pre>

<p><img src="https://forum.processing.org/two/uploads/imageupload/218/J7M0XTHVQVN8.PNG" alt="Capture" title="Capture" /></p>
]]></description>
   </item>
   <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>Issue loading xml-feed in p5js</title>
      <link>https://forum.processing.org/two/discussion/22668/issue-loading-xml-feed-in-p5js</link>
      <pubDate>Fri, 19 May 2017 16:01:49 +0000</pubDate>
      <dc:creator>Andreas_Ref</dc:creator>
      <guid isPermaLink="false">22668@/two/discussions</guid>
      <description><![CDATA[<p>Hey</p>

<p>I am having issues loading simple xml-feeds in p5.js. It seems like the feed never loads?</p>

<p>The link for the (example) xml feed is <a rel="nofollow" href="http://ekstrabladet.dk/rss2/?mode=normal&amp;submode=sport">ekstrabladet.dk/rss2/?mode=normal&amp;submode=sport</a>. I am using the p5.js editor.</p>

<pre><code>var xml;

function preload() {
  var url = '<a href="http://ekstrabladet.dk/rss2/?mode=normal&amp;submode=sport'" target="_blank" rel="nofollow">http://ekstrabladet.dk/rss2/?mode=normal&amp;submode=sport'</a>;
  xml = loadXML(url);
}

function setup() {
  print(xml);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Origin is off canvas on Windows machine, displays correctly on Mac</title>
      <link>https://forum.processing.org/two/discussion/23908/origin-is-off-canvas-on-windows-machine-displays-correctly-on-mac</link>
      <pubDate>Thu, 24 Aug 2017 00:12:35 +0000</pubDate>
      <dc:creator>timrolls</dc:creator>
      <guid isPermaLink="false">23908@/two/discussions</guid>
      <description><![CDATA[<p>We're working on some code that builds LED layouts based on SVG files, and encountered something strange.</p>

<p>On my Windows 10 machine, the origin is approximately 25 pixels above the start of the output window.
There are no transform methods, matrix transformations, or rectMode statements that would cause something like this.
Even stranger, running the same code on OSX displays correctly.</p>

<p>screenshot: <a href="http://prntscr.com/gcaejgs" target="_blank" rel="nofollow">http://prntscr.com/gcaejgs</a>
The rect in the top right is being constructed by rect(0,0,50,50); for testing purpose.</p>

<p>The code in question is here: <a href="https://github.com/PWRFLcreative/Lightwork-Scraper" target="_blank" rel="nofollow">https://github.com/PWRFLcreative/Lightwork-Scraper</a>
It should run regardless of whether there's a fadecandy driving LEDs on the network.</p>

<p>Has anyone encountered something like this?</p>
]]></description>
   </item>
   <item>
      <title>p5js: calling loadXML outside of preload()</title>
      <link>https://forum.processing.org/two/discussion/23348/p5js-calling-loadxml-outside-of-preload</link>
      <pubDate>Fri, 07 Jul 2017 11:34:11 +0000</pubDate>
      <dc:creator>Andreas_Ref</dc:creator>
      <guid isPermaLink="false">23348@/two/discussions</guid>
      <description><![CDATA[<p>Hey</p>

<p>I am trying to make a sketch where I use loadXML outside of preload, because I want to be able to dynamically load the xml from different urls, determined by the user.</p>

<p>How would I best do that? Every time I call loadXML outside of preload in I get errors.</p>
]]></description>
   </item>
   <item>
      <title>Determining the child count of a XML element where the children have unique names</title>
      <link>https://forum.processing.org/two/discussion/6603/determining-the-child-count-of-a-xml-element-where-the-children-have-unique-names</link>
      <pubDate>Sun, 03 Aug 2014 08:52:25 +0000</pubDate>
      <dc:creator>jvolker</dc:creator>
      <guid isPermaLink="false">6603@/two/discussions</guid>
      <description><![CDATA[<p>I'm having problems with determining the number of children of an XML element, where the child elements don't have the same name / unique names.</p>

<p>This is part of the XML file:</p>

<pre><code>&lt;process&gt;
    &lt;f0&gt;255.0000&lt;/f0&gt;
    &lt;f1&gt;238.2833&lt;/f1&gt;
    &lt;f2&gt;222.1333&lt;/f2&gt;
    &lt;f3&gt;206.5500&lt;/f3&gt;
    &lt;f4&gt;191.5333&lt;/f4&gt;
    &lt;f5&gt;177.0833&lt;/f5&gt;
    &lt;f6&gt;163.2000&lt;/f6&gt;
    &lt;f7&gt;149.8833&lt;/f7&gt;
    &lt;f8&gt;137.1333&lt;/f8&gt;
    &lt;f9&gt;124.9500&lt;/f9&gt;
    &lt;f10&gt;113.3333&lt;/f10&gt;
    &lt;f11&gt;102.2833&lt;/f11&gt;
    &lt;f12&gt;91.8000&lt;/f12&gt;
    &lt;f13&gt;81.8833&lt;/f13&gt;
    &lt;f14&gt;72.5333&lt;/f14&gt;
    &lt;f15&gt;63.7500&lt;/f15&gt;
    &lt;f16&gt;55.5333&lt;/f16&gt;
    &lt;f17&gt;47.8833&lt;/f17&gt;
    &lt;f18&gt;40.8000&lt;/f18&gt;
    &lt;f19&gt;34.2833&lt;/f19&gt;
    &lt;f20&gt;28.3333&lt;/f20&gt;
    &lt;f21&gt;22.9500&lt;/f21&gt;
    &lt;f22&gt;18.1333&lt;/f22&gt;
    &lt;f23&gt;13.8833&lt;/f23&gt;
    &lt;f24&gt;10.2000&lt;/f24&gt;
    &lt;f25&gt;7.0833&lt;/f25&gt;
    &lt;f26&gt;4.5333&lt;/f26&gt;
    &lt;f27&gt;2.5500&lt;/f27&gt;
    &lt;f28&gt;1.1333&lt;/f28&gt;
    &lt;f29&gt;0.2833&lt;/f29&gt;
    &lt;f30&gt;0.0000&lt;/f30&gt;
&lt;/process&gt;
</code></pre>

<p>Using <code>process.getChildCount()</code> I would expect it to return 31. But it does return 63. So does <code>process.getChildren().length</code>.<br />
I found this <a rel="nofollow" href="https://code.google.com/p/processing/issues/detail?id=975#c2">thread</a> about calling <code>getChildren()</code> without parameter which doesn't ignore whitespace.<br />
Good to know, but why is not ignoring whitespace useful and wouldn't a parameter to turn on/off ignoring of whitespace be good here?</p>

<p>In most other threads I found it was simply suggested to call <code>getChildren()</code> <strong>with</strong> parameter to match exactly the child elements you need. But in my case this is not an option since all elements have different names.<br />
So I could now loop through the array returned by <code>process.getChildren()</code>, while building a new array and use <code>child.getName()</code> to exclude elements that are empty or return <code>#text</code> from being added to the new array. But this is a lot of work I think and not the behavior I would expect.<br />
Are there better solutions for this?</p>

<p>Finally I wonder why some elements using <code>child.getName()</code> return <code>#text</code> and some are empty.</p>

<p>Thanks for any comments on this!</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>xml.getChildCount returns wrong value</title>
      <link>https://forum.processing.org/two/discussion/21038/xml-getchildcount-returns-wrong-value</link>
      <pubDate>Mon, 27 Feb 2017 18:05:57 +0000</pubDate>
      <dc:creator>linus</dc:creator>
      <guid isPermaLink="false">21038@/two/discussions</guid>
      <description><![CDATA[<p>Hi, this xml file:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;Structure&gt;
      &lt;Start x="0" y="0"/&gt;
      &lt;Goal x="100" y="100"/&gt;
      &lt;Blocks&gt;
        &lt;_0 x="250" y="100"/&gt;
        &lt;_1 x="250" y="150"/&gt;
        &lt;_2 x="250" y="200"/&gt;
        &lt;_3 x="250" y="250"/&gt;
        &lt;_4 x="250" y="300"/&gt;
      &lt;/Blocks&gt;
    &lt;/Structure&gt;
</code></pre>

<p>with this source code:</p>

<pre><code>XML xml, blocks;

void setup() {

  xml = loadXML("level.xml");
  blocks = xml.getChild("Blocks");

  println(blocks.getChildCount());
}
</code></pre>

<p>returns 11 in the console. But the tag "Blocks" just has 5 child elements. What am I doing wrong?</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>minim: 1st clip doesn't play on 1st play()</title>
      <link>https://forum.processing.org/two/discussion/19651/minim-1st-clip-doesn-t-play-on-1st-play</link>
      <pubDate>Sat, 10 Dec 2016 20:04:25 +0000</pubDate>
      <dc:creator>pop451</dc:creator>
      <guid isPermaLink="false">19651@/two/discussions</guid>
      <description><![CDATA[<p>In my simple picture dictionary code cited below, I add the last line in setup() [line 29], i.e. preload the 1st sound clip, or else it doesn't play on 1st instance of play().</p>

<p>I guess this is not the best solution. Any advice?</p>

<pre><code>import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer player;

PImage image, imageSprite;
int sX, sY, eX, eY ;
XML fruitList ;
XML[] fruits ;
int click;
String name, thisPage, startMessage;

void setup() {
  size(600, 400) ;
  minim = new Minim(this);
  click = 0 ;
  name ="";
  thisPage = "";

  image = loadImage("fruits.jpg") ;
  fruitList = loadXML("fruitList.xml") ;
  fruits = fruitList.getChildren("fruit") ;
  startMessage = "In this lesson, you will learn " + fruits.length + " words.\nLeft-click to start &amp; go next. \nRight-click to go back." ;

  player = minim.loadFile("0.mp3", 2048); // to preload the initial sound clip
}

void draw() {
  if (click == 0) {
    background(255) ;
    textSize(20);
    fill(0);
    text(startMessage, width/2 - textWidth(startMessage)/2, height/2 - 40);
  } else {
    background(255) ;
    name = fruits[click-1].getChild("name").getContent();
    fill(0);
    textSize(40);
    text(name, width/2 - textWidth(name)/2, 60);


    sX = int(fruits[click-1].getChild("get/sX").getContent());
    sY = int(fruits[click-1].getChild("get/sY").getContent());
    eX = int(fruits[click-1].getChild("get/eX").getContent());
    eY = int(fruits[click-1].getChild("get/eY").getContent());
    imageSprite = image.get(sX, sY, eX - sX, eY - sY);
    image(imageSprite, width/2 - imageSprite.width/2, height/2 - imageSprite.height/2) ;

    thisPage = click + "/" + fruits.length ;
    fill(127);
    textSize(20);
    text(thisPage, width - textWidth(thisPage), height -25);
  }
}

void mouseClicked () {
  if (mouseButton == LEFT) {
    click++ ;
  } else if (mouseButton == RIGHT) {
    click-- ;
  }
  click = constrain(click, 1, fruits.length);

  player = minim.loadFile(click-1 + ".mp3", 2048); // 1024, 2048
  player.setGain(-20);
  player.play();
}
</code></pre>
]]></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>How to call thread("functionName") in draw()</title>
      <link>https://forum.processing.org/two/discussion/18591/how-to-call-thread-functionname-in-draw</link>
      <pubDate>Mon, 17 Oct 2016 10:25:03 +0000</pubDate>
      <dc:creator>Julo</dc:creator>
      <guid isPermaLink="false">18591@/two/discussions</guid>
      <description><![CDATA[<p>How to call thread("functionName") in draw() with when the function is in a class in other tab?
if I put the function in the main class, it has no problem.
If I put them in a class in other tab, I get
"There is no public functionName() method in the class xxxxxx" msg.</p>
]]></description>
   </item>
   <item>
      <title>load local xml file</title>
      <link>https://forum.processing.org/two/discussion/18186/load-local-xml-file</link>
      <pubDate>Fri, 16 Sep 2016 14:20:19 +0000</pubDate>
      <dc:creator>matthieu</dc:creator>
      <guid isPermaLink="false">18186@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm trying to load local xml file whitout sucess. My variable is empty and I have
always this error : no content type found for .xml</p>

<p>I don't think it's a browser bug because the function loadStrings() works well.
But even to translate this string to xml, I have the same error
Here's the code :</p>

<pre><code>var chants;
function setup() {
}
function draw() {
  text(chants, 20 , 30);
}
function preload(){  
  chants = loadXML("assets/chants.xml");
}
</code></pre>

<p>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>How to extend built-in objects?</title>
      <link>https://forum.processing.org/two/discussion/17028/how-to-extend-built-in-objects</link>
      <pubDate>Tue, 07 Jun 2016 19:29:58 +0000</pubDate>
      <dc:creator>Minesha</dc:creator>
      <guid isPermaLink="false">17028@/two/discussions</guid>
      <description><![CDATA[<p>I'm building a fancy XML parser/editor right now, and the syntax of my XML file gives every element a unique ID attribute. I wrote a function that returns a child element if it has an attribute whose value... You know what? Just take a look.</p>

<pre><code>XML getChildAttr(XML Parent, String Attribute, String Value) {
  if (Parent.hasChildren()) {
    for (XML childN : Parent.getChildren()) {
      if (childN.getString(Attribute) != null) {
        if (childN.getString(Attribute).equals(Value)) {
          println(childN);
          return childN;
        }
      }
    }
  }
  return null;
}
</code></pre>

<p>I wish to be able to call it like this: <code>Parent.getChildAttr(Attribute, Value);</code>, but that would require it to be a method of the XML class. My question is this: Is it possible to add methods to built-in classes? If it is, how would I do so?</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>Structuring the code</title>
      <link>https://forum.processing.org/two/discussion/16424/structuring-the-code</link>
      <pubDate>Wed, 04 May 2016 16:59:21 +0000</pubDate>
      <dc:creator>noelleau</dc:creator>
      <guid isPermaLink="false">16424@/two/discussions</guid>
      <description><![CDATA[<p>Sorry to post it here, but I'm having a huge problem structuring my code. I have just started working with processing, so I'm more of a beginner. Would really appreciate if anyone could help me with this.</p>

<p>The idea behind my project is to be able to control the amount of negative and positive information we want to see. I tried to combine rss reader code of two different websites and make a working slider that would change the background colour. Headlines of the bad news would be displayed in black and the good news would be in white. Depending on type of information we want to see, the background would change from black to white revealing only headlines we want to read.</p>

<p>This is a v simple idea, been trying to structure it out so the headlines would work in colour too but I don't think I've got enough knowledge to do so.</p>

<p>rss code:</p>

<pre><code>String[] titles;
String[] titles2;


PFont font;
//color textColor = 255;
void setup() {
  size(1450,860);
  background(0);
  noStroke();
  smooth(); 

  // Setup font
  font = loadFont("din.vlw");
  textFont(font, 18);

  // Load RSS feed

  String url = "<a href="https://feedity.com/reddit-com/W1FRU1ZV.rss" target="_blank" rel="nofollow">https://feedity.com/reddit-com/W1FRU1ZV.rss</a>"; 
  XML rss = loadXML(url);
  //println(rss.listChildren());

  // 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();


    titles[i] = title;
  }

    String url2 = "<a href="https://feedity.com/reddit-com/W1FRU1ZW.rss" target="_blank" rel="nofollow">https://feedity.com/reddit-com/W1FRU1ZW.rss</a>";
  XML rss2 = loadXML(url2);
  // Get title of each element
  //println(rss2.listChildren());

  XML[] title2XMLElements = rss2.getChildren("channel/item/title");
  titles2 = new String[title2XMLElements.length];
  for (int i = 0; i &lt; title2XMLElements.length; i++) {
    String title2 = title2XMLElements[i].getContent();
    // Store title in array for later use
    titles2[i] = title2; }

}

void draw() {
background(255); 

  for (int i = 0; i &lt; titles.length; i++) {
    float y = (i+1) * 15;

    fill(0, 220);
    text(titles[i], 100, y*6, 500, 200);   

  }  

  for (int i = 0; i &lt; titles2.length; i++) {
    float y = (i+1) * 15;

    fill(0); 
    text(titles2[i], 800, y*6, 500, 100);
}
}
</code></pre>

<p>Slider ( got this one from <a href="http://www.sojamo.de/" target="_blank" rel="nofollow">http://www.sojamo.de/</a> and been trying to use some parts of it)</p>

<pre><code>PGraphics letters;   //news headlines
PGraphics sliders;   //control sliders/background colour 

import controlP5.*;

ControlP5 cp5;

int myColor = color(255);
int c1,c2;
float n,n1;


void setup() {
  size(400,600);
  noStroke();
  cp5 = new ControlP5(this);

  letters = createGraphics(width, height);
  sliders = createGraphics(width, height); 



  // create a new button with name 'buttonA'
  cp5.addButton("colorA")
     .setValue(0)
     .setPosition(100,100)
     .setSize(200,19)
     ;

  // and add another 2 buttons
  cp5.addButton("colorB")
     .setValue(100)
     .setPosition(100,120)
     .setSize(200,19)
     ;



}

void draw() {
  background(myColor);
  myColor = lerpColor(c1,c2,n);
  n += (1-n)* 0.1; 
}

public void controlEvent(ControlEvent theEvent) {
  println(theEvent.getController().getName());
  n = 0;
}

// function colorA will receive changes from 
// controller with name colorA
public void colorA(int theValue) {
  println("a button event from colorA: "+theValue);
  c1 = c2;
  c2 = color(0,0,0);
}

// function colorB will receive changes from 
// controller with name colorB
public void colorB(int theValue) {
  println("a button event from colorB: "+theValue);
  c1 = c2;
  c2 = color(255);
}


public void play(int theValue) {
  println("a button event from buttonB: "+theValue);
  c1 = c2;
  c2 = color(0,0,0);
}
</code></pre>

<p>I have been trying to use PGraphics but again, I cannot think what's the best way to structure my code. 
I'd really appreciate any help,</p>

<p>Thank you!!</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>loadXML() results in error</title>
      <link>https://forum.processing.org/two/discussion/15688/loadxml-results-in-error</link>
      <pubDate>Fri, 25 Mar 2016 14:52:15 +0000</pubDate>
      <dc:creator>FeliciaE</dc:creator>
      <guid isPermaLink="false">15688@/two/discussions</guid>
      <description><![CDATA[<p>Hello, 
I need to get a value from a web page and use this in my p5.js sketch. I do this by using the loadXML command, but it does not work. What I want to achieve is getting a string with the source code of the web page, so that I can get the value out of this string. I tried to do this with the following code:</p>

<pre lang="javascript">
function setup() {
  createCanvas(200, 200);
  var url = '<a href="http://creators.ewi.utwente.nl/site/s1712187/SmartPad/'" target="_blank" rel="nofollow">http://creators.ewi.utwente.nl/site/s1712187/SmartPad/'</a>;
  loadXML(url, callback, error);
}

function draw() {
  
}

function callback() {
  print("it is callback");
}

function error() {
  print("it is error");
}
</pre>

<p>"It is error" is the line that is printed when I run the sketch.
Who knows what my mistake is?? Of course the code should be extended by creating a string and reading the data etc. but first the loadXML function should load the html source code properly.</p>

<p>(The only examples that I can find are based on JSON instead of XML.)</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>How can get the weather in a simple sketch?</title>
      <link>https://forum.processing.org/two/discussion/14108/how-can-get-the-weather-in-a-simple-sketch</link>
      <pubDate>Tue, 22 Dec 2015 02:57:05 +0000</pubDate>
      <dc:creator>solidbeta</dc:creator>
      <guid isPermaLink="false">14108@/two/discussions</guid>
      <description><![CDATA[<p>Hi! Im following this tutorial -&gt; <a href="http://learningprocessing.dreamhosters.com/exercises/chapter-18/exercise-18-12/" target="_blank" rel="nofollow">http://learningprocessing.dreamhosters.com/exercises/chapter-18/exercise-18-12/</a></p>

<p>but the library <strong>simpleML</strong>, not exists now. How I can solve this? Another library?</p>

<p>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>how to read the text of a web page</title>
      <link>https://forum.processing.org/two/discussion/13242/how-to-read-the-text-of-a-web-page</link>
      <pubDate>Sun, 25 Oct 2015 13:32:02 +0000</pubDate>
      <dc:creator>ondsinet_</dc:creator>
      <guid isPermaLink="false">13242@/two/discussions</guid>
      <description><![CDATA[<p>For a statistical research I've made a program that counts and stores what and how often words are used. Now it reads form a txt file but I would like to extend the statistics to the internet.
There are tuorials on how to read the text from a web page, but I just need the written text, not the code part; Is there a distinction that I can use? 
The program should read every file in a domain; As an example, I should say the link is "<a href="https://www.processing.org/" target="_blank" rel="nofollow">https://www.processing.org/</a>" and it should read the texts on the presentations, the tutorials ecc, but not the html part.</p>

<p>It started as a project on my favourite singer, but I soon discovered I'm wayyyy to lazy to copy and paste his 100+ songs to a .txt file.</p>
]]></description>
   </item>
   <item>
      <title>Problems with æøå characters in XML</title>
      <link>https://forum.processing.org/two/discussion/11860/problems-with-aeoa-characters-in-xml</link>
      <pubDate>Mon, 27 Jul 2015 23:14:52 +0000</pubDate>
      <dc:creator>Andreas_Ref</dc:creator>
      <guid isPermaLink="false">11860@/two/discussions</guid>
      <description><![CDATA[<p>Hi</p>

<p>This is my first post in here. 
I have a simple problem with getting Scandinavian characters back from a xml. Æ, Ø and Å all come out wrong from this code.</p>

<pre><code>String url = "<a href="http://suggestqueries.google.com/complete/search?output=toolbar&amp;hl=dk&amp;q=" target="_blank" rel="nofollow">http://suggestqueries.google.com/complete/search?output=toolbar&amp;hl=dk&amp;q=</a>ærø";

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

  for (int i = 0; i &lt; children.length; i++) {
    XML suggestion = children[i].getChild("suggestion");
    println(suggestion);
  } 
}
</code></pre>

<p>If you visit the url <a rel="nofollow" href="http://suggestqueries.google.com/complete/search?output=toolbar&amp;hl=dk&amp;q=ærø">http://suggestqueries.google.com/complete/search?output=toolbar&amp;hl=dk&amp;q=ærø</a> you see, that the characters Æ, Ø Å all work fine on the url itself.</p>

<p>Help is much appreciated.</p>

<p>Regards 
Andreas from Denmark</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>
   </channel>
</rss>