How to find certain items in an xml?

2019-07-30 06:49发布

问题:

I have an xml and all, and the good thing is, I can run it in processing. So when I press run, in the box in the bottom I get all the scores of all the teams. Why, here's the code:

XML xml;

void setup() {
  xml = loadXML("http://www.scorespro.com/rss2/live-basketball.xml");
  XML[] channel = xml.getChildren("channel");
   //println(xml);
  for (int i = 0; i < channel.length; i++) {
    String item = channel[i].getString("title");
    String name = channel[i].getContent();
    println(channel);
  }
}

Now I am wondering. I only want to get for example the Miami Heat's score. Is that possible?

回答1:

Processing has a built-in XML library that can do exactly what you're looking for.