We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
code was cut source is https://processing.org/reference/XML_getChild_.html /* The following short XML file called "mammals.xml" is parsed in the code below. It must be in the project's "data" folder.*/
<?xml version="1.0"?> Goat Leopard Zebra
I think you want getChildren() -- something like this:
See the basic reference example: