GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Processing
  • p5.js
  • Processing.py
  • Processing for Android
  • Processing for Pi
  • Processing Foundation

This view

  • Original page
  • New address

GeezerVison is showing py.processing.org — loadXML() \ Language (API)

Python Mode for Processing is no longer maintained. This site is kept as an archive. Read more
  • Processing
  • p5.js
  • Processing.py
  • Processing for Android
  • Processing for Pi
  • Processing Foundation
Cover
Reference
Tutorials
Examples
Bugs
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 = loadXML("mammals.xml")
children = xml.getChildren("animal")
for i in range(len(children)):
		id = children[i].getInt("id")
		coloring = children[i].getString("species")
		name = children[i].getContent()
		print("%i, %s, %s" % (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
filenameString: name of a file in the data folder or a URL.
Related XML
parseXML()
saveXML()
loadBytes()
loadStrings()
loadTable()

Updated on Sat Oct 24 11:26:09 2026.

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

Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.