88
99var p5 = require ( '../core/core' ) ;
1010
11-
11+ /**
12+ * XML is a representation of an XML object, able to parse XML code. Use
13+ * loadXML() to load external XML files and create XML objects.
14+ *
15+ * @class p5.XML
16+ * @constructor
17+ * @return {p5.XML } p5.XML object generated
18+ * @example
19+ * <div class='norender'><code>
20+ * // The following short XML file called "mammals.xml" is parsed
21+ * // in the code below.
22+ * //
23+ * // <?xml version="1.0"?>
24+ * // <mammals>
25+ * // <animal id="0" species="Capra hircus">Goat</animal>
26+ * // <animal id="1" species="Panthera pardus">Leopard</animal>
27+ * // <animal id="2" species="Equus zebra">Zebra</animal>
28+ * // </mammals>
29+ *
30+ * var xml;
31+ *
32+ * function preload() {
33+ * xml = loadXML("assets/mammals.xml");
34+ * }
35+ *
36+ * function setup() {
37+ * var children = xml.getChildren("animal");
38+ *
39+ * for (var i = 0; i < children.length; i++) {
40+ * var id = children[i].getNumber("id");
41+ * var coloring = children[i].getString("species");
42+ * var name = children[i].getContent();
43+ * print(id + ", " + coloring + ", " + name);
44+ * }
45+ * }
46+ *
47+ * // Sketch prints:
48+ * // 0, Capra hircus, Goat
49+ * // 1, Panthera pardus, Leopard
50+ * // 2, Equus zebra, Zebra
51+ * </code></div>
52+ */
1253p5 . XML = function ( ) {
1354 this . name = null ; //done
1455 this . attributes = { } ; //done
@@ -750,3 +791,4 @@ p5.XML.prototype._setAttributes = function(node) {
750791 this . attributes = att ;
751792} ;
752793
794+ module . exports = p5 . XML ;
0 commit comments