Name

parseXML()

Examples
data = "<mammals><animal>Goat</animal></mammals>"
xml = parseXML(data)
if xml == None:
  print("XML could not be parsed.")
else:
  firstChild = xml.getChild("animal")
  print(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)
Related XML
loadXML()
saveXML()

Updated on Mon Sep 21 15:53:25 2020.

If you see any errors or have comments, please let us know.