XML newbie: how to access 2nd child

edited January 2018 in Questions about Code

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

<?xml version="1.0"?> // // Goat // Leopard // Zebra //

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

Any help would be appreciated

/----------- XML xml;

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

// Sketch prints: // Goat //----------

Answers

Sign In or Register to comment.