- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Name | ### loadXML()
Examples |
    // 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"?>
    // <mammals>
    //   <animal id="0" species="Capra hircus">Goat</animal>
    //   <animal id="1" species="Panthera pardus">Leopard</animal>
    //   <animal id="2" species="Equus zebra">Zebra</animal>
    // </mammals>

    XML xml;

    void setup() {
      xml = loadXML("mammals.xml");
      XML[] children = xml.getChildren("animal");

      for (int i = 0; i < 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
Description | Reads the contents of a file or URL and creates an XML object with its values. If a file is specified, it must be located in the sketch's "data" folder. The filename parameter can also be a URL to a file found online. All files loaded and saved by the Processing API use UTF-8 encoding. If you need to load an XML file that's not in UTF-8 format, see the developer's reference for the XML object.
Syntax |
    loadXML(filename)
Parameters |
filename | String: name of a file in the data folder or a URL.
Returns | XML
Related | XML parseXML() saveXML() loadBytes() loadStrings() loadTable()

Updated on July 4, 2018 11:56:42am EDT