loading xml

edited October 2015 in Questions about Code

Hello I've one xml on the internet. there are are many values with the same ID. I mean there's an XXX child, well I can display the first child, but how to display the second? or all values with a child XXX? Could you please help me? thanks guys!

Answers

  • Look in reference

    See xml loadXml etc.

  • Could you link me little bit please? in the xml are 4 lines with element (all 100% identical), I want to see them all, but I am able to load just one value.

  • I provided a link to the XML documentation above. If that doesn't help then explain the problem a little more clearly, ideally with a code example of the problem you're trying to solve, or an example of the XML you're trying to parse.

  • @blindfish the xml is the same like in my other example http://xml.weather.yahoo.com/forecastrss?p=10003 do you see the yweather:forecast on the bottom? there are day values, I'd like to use them all, not only the first one. That's what I thought, sorry for bad explanation.

    I don't think my code would help, it's normally uploaded, working but I can load just value in the first line. I need to get access to the rest

    ...
    XML forecast = xml.getChild("channel/item/yweather:forecast");
    high = forecast.getInt("high");
    highTomorrow = forecast.getInt("high"); // <- here something what would link it to the second line, to the value of tomorrow temeprature
    ...
    
  • edited November 2015

    A lot easier to track the problem, now you provide more info ;)
    So if you use getChildren() instead of getChild(), you get an array and can iterate over it.

    XML xml = loadXML("http://" + "xml.weather.yahoo.com/forecastrss?p=10003");
    XML[] children = xml.getChildren("channel/item/yweather:forecast");
    for(int i =0; i< children.length; i++){
      println(children[i].getInt("high"));
    }
    
Sign In or Register to comment.