- 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 | ### parseXML()
Examples |
    String data = "<mammals><animal>Goat</animal></mammals>";

    void setup() {
      XML xml = parseXML(data);
      if (xml == null) {
        println("XML could not be parsed.");
      } else {
        XML firstChild = xml.getChild("animal");
        println(firstChild.getContent());
      }
    }

    // Sketch prints:
    // Goat
Description | Takes a String, parses its contents, and returns an XML object. If the String does not contain XML data or cannot be parsed, a null value is returned. parseXML() is most useful when pulling data dynamically, such as from third-party APIs. Normally, API results would be saved to a String, and then can be converted to a structured XML object using parseXML(). Be sure to check if null is returned before performing operations on the new XML object, in case the String content could not be parsed. If your data already exists as an XML file in the data folder, it is simpler to use loadXML().
Syntax |
    parseXML(xmlString)
    parseXML(xmlString, options)
Parameters |
xmlString | String: the content to be parsed as XML
Returns | XML
Related | XML loadXML() saveXML()

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