<?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 getcontent() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=getcontent%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:54:24 +0000</pubDate>
         <description>Tagged with getcontent() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedgetcontent%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>Unable to use substring() function within an array. (Parsing irishrail)</title>
      <link>https://forum.processing.org/two/discussion/27687/unable-to-use-substring-function-within-an-array-parsing-irishrail</link>
      <pubDate>Wed, 04 Apr 2018 01:03:33 +0000</pubDate>
      <dc:creator>Neowso</dc:creator>
      <guid isPermaLink="false">27687@/two/discussions</guid>
      <description><![CDATA[<p>I am getting an error when I attempt to use substring() as I iterate through an array. I want to extract an integer from a string of text. This works fine outside of an array:</p>

<pre><code>    String trainInfo = "E215\n17:30 - Howth to Bray (-3 mins late)\nArrived Dublin Connolly next stop Tara Street";
    int start      = trainInfo.indexOf("(" ) + 1;  // STEP 1 
    int end        = trainInfo.indexOf(" mins", start);      // STEP 2
    String status  = trainInfo.substring(start, end);    // STEP 3
    int status_no   = int(status);                    // STEP 4
    println(status_no);
</code></pre>

<p>Whereas in my case I get an error at the point of the substring():</p>

<pre><code>    void requestData() {   
      for (int i = 0; i &lt; children.length; i++) {     

        XML announcementElement = children[i].getChild("PublicMessage");
        String announcement = announcementElement.getContent(); 

        int start      = announcement.indexOf("(" ) + 1;        // STEP 1 
        int end        = announcement.indexOf(" mins", start);  // STEP 2
        String status  = announcement.substring(start, end);    // STEP 3    ***error thrown at this point***
        int status_no   = int(status);                          // STEP 4

        println(status_no);
      }
    } 
</code></pre>

<p>[edit] Though not strictly related to Processing, I found a thread in the following forum that indicates that javascript does not permit substrings within arrays. I guess the same applies to Processing?:
<a rel="nofollow" href="https://stackoverflow.com/questions/42429413/javascript-error-array-substring-is-not-a-function">https://stackoverflow.com/questions/42429413/javascript-error-array-substring-is-not-a-function</a></p>

<p>The responder recommends to "slice and then remove the commas" or to use join(''). I have tried to to slice() and join(), based on Processing documentation but it's not working out.</p>

<p>Would anyone know of a way to get around this? Many thanks :)</p>
]]></description>
   </item>
   <item>
      <title>trouble comparing JSON getString result with string</title>
      <link>https://forum.processing.org/two/discussion/26384/trouble-comparing-json-getstring-result-with-string</link>
      <pubDate>Fri, 16 Feb 2018 16:46:43 +0000</pubDate>
      <dc:creator>Quebecsti</dc:creator>
      <guid isPermaLink="false">26384@/two/discussions</guid>
      <description><![CDATA[<p>Hello</p>

<p>I'm trying to learn the JSON and it's intricacies.</p>

<p>I'm using the JSONget example as a starter.. I want to do conditionnals, but it never returns true.</p>

<p>Even using the debugger, it all seem ok and the same, 
t and a will give type java.lang.String = "Wilbert"</p>

<p>what am I missing here?  I'm confused..</p>

<p>Thanks for the help</p>

<p>---- CODE --</p>

<pre><code>import http.requests.*;

public void setup() 
{
    size(100,100);
    smooth();

  GetRequest get = new GetRequest("<a href="http://connect.doodle3d.com/api/list.example" target="_blank" rel="nofollow">http://connect.doodle3d.com/api/list.example</a>");
  get.send(); // program will wait untill the request is completed
  println("response: " + get.getContent());

  JSONObject response = parseJSONObject(get.getContent());


  println("status: " + response.getString("status"));
  JSONArray boxes = response.getJSONArray("data");

  println("boxes: ");
  for(int i=0;i&lt;boxes.size();i++) {
    JSONObject box = boxes.getJSONObject(i);

    String t = box.getString("wifiboxid");
    String a = "Wilbert";

    println("t : "+ t);      //confirms the name to compare
    println(t.length());  // confirms length, so no extra characters
    println(a.length()); // confirms length, so no extra characters

    if ( t == a)  // compare but never true
      { 
       println("  wifiboxid: " + box.getString("wifiboxid"));
       println("   remoteip: " + box.getString("remoteip"));
      }
  }
}
</code></pre>

<p>---- JSON -----</p>

<p><a href="http://connect.doodle3d.com/api/list.example" target="_blank" rel="nofollow">http://connect.doodle3d.com/api/list.example</a></p>

<pre><code>    { 
        "status":"success",
        "data":[
                {
                    "id":"62.216.8.197\/10.0.0.18",
                    "remoteip":"62.216.8.197",
                    "localip":"10.0.0.18",
                    "wifiboxid":"Albert",
                    "hidden":"0",
                    "date":"2013-10-03 17:24:33",
                },
                {
                    "id":"62.216.8.197\/10.0.0.29",
                    "remoteip":"62.216.8.197",
                    "localip":"10.0.0.29",
                    "wifiboxid":"Wilbert",
                    "hidden":"0",
                    "date":"2013-10-03 17:52:19"
                }
               ],
    }
</code></pre>
]]></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>Android mode: select input not working.. How can I dynamically load images?</title>
      <link>https://forum.processing.org/two/discussion/23875/android-mode-select-input-not-working-how-can-i-dynamically-load-images</link>
      <pubDate>Mon, 21 Aug 2017 11:28:43 +0000</pubDate>
      <dc:creator>yousufalin</dc:creator>
      <guid isPermaLink="false">23875@/two/discussions</guid>
      <description><![CDATA[<p>Hi there!,</p>

<p>I was trying to use the <code>selectInput</code>for loading an image in processing android mode and it didn't work. I also tried to use the SelectFile library, which is unfortunately not working with the latest processing.</p>

<p>any other libraries or methods to dynamically load image?</p>

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

<p>Thanks in advance :)</p>
]]></description>
   </item>
   <item>
      <title>HTTP Request</title>
      <link>https://forum.processing.org/two/discussion/22202/http-request</link>
      <pubDate>Tue, 25 Apr 2017 19:07:03 +0000</pubDate>
      <dc:creator>PauloBenson</dc:creator>
      <guid isPermaLink="false">22202@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>Im trying to request some information from a public transportation web site. I'm using the HTTP Request Library. And it have to POST an authentication for then  a GET to fetch the information.i'm getting a True return from the POST authentication... but a message : authorization denied.</p>

<p>Any Help?</p>

<pre><code>import http.requests.*;

public void setup() 
{
    size(400,400);
    smooth();
  String searchLinha = "8000";


    PostRequest post = new PostRequest("http:" + "//api.olhovivo.sptrans.com.br/v0/Login/Autenticar?token=4af5e3112da870ac5708c48b7a237b30206806f296e1d302e4cb611660e2e03f");



  GetRequest linhas = new GetRequest("http:" + "//api.olhovivo.sptrans.com.br/v0/Linha/CarregarDetalhes?codigoLinha");

  post.send();
  linhas.send();

  System.out.println("Reponse Content: " + post.getContent());
  System.out.println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));

  System.out.println("Reponse Content: " + linhas.getContent());
  System.out.println("Reponse Content-Length Header: " + linhas.getHeader("Content-Length"));


}
</code></pre>

<p>the Console:</p>

<pre><code>Apr 25, 2017 3:37:39 PM org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {}
Reponse Content: true
Reponse Content-Length Header: 4
Reponse Content: {"Message":"Authorization has been denied for this request."}
Reponse Content-Length Header: 61
</code></pre>
]]></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>Retrieve quotes from brainyquote.com</title>
      <link>https://forum.processing.org/two/discussion/22223/retrieve-quotes-from-brainyquote-com</link>
      <pubDate>Wed, 26 Apr 2017 13:44:51 +0000</pubDate>
      <dc:creator>CharlesDesign</dc:creator>
      <guid isPermaLink="false">22223@/two/discussions</guid>
      <description><![CDATA[<p>Hi All,</p>

<p>I'm trying to retrieve some quotes from this page with not much luck. <a href="https://www.brainyquote.com/quotes/topics/topic_knowledge.html" target="_blank" rel="nofollow">https://www.brainyquote.com/quotes/topics/topic_knowledge.html</a></p>

<p>I've tried both loadStringI() and loadXml(), what other options do I have?</p>

<p>Thanks,
Charles</p>
]]></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>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>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>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>Sending a HTTP Get Request</title>
      <link>https://forum.processing.org/two/discussion/15978/sending-a-http-get-request</link>
      <pubDate>Tue, 12 Apr 2016 02:16:54 +0000</pubDate>
      <dc:creator>jlingley</dc:creator>
      <guid isPermaLink="false">15978@/two/discussions</guid>
      <description><![CDATA[<p>Hi There. I have a few students who are attempting to send a get request from processing to retrieve their SCRATCH cloud data. I have instructed them to use the following: GET <a href="https://scratch.mit.edu/varserver/105015849" target="_blank" rel="nofollow">https://scratch.mit.edu/varserver/105015849</a></p>

<p>The Processing.org sketch looks like this:</p>

<pre><code>import http.requests.*;

GetRequest get = new GetRequest("<a href="https://scratch.mit.edu/varserver/105015849" target="_blank" rel="nofollow">https://scratch.mit.edu/varserver/105015849</a>“);
get.send();
get.addHeader(”Accept“, ”application/json“);
println(”Response Content: " +get.getContent());
</code></pre>

<p>However, no response is provided. Any suggestions?</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>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>
   </channel>
</rss>