trouble trying to load in an XML file to processing
in
Programming Questions
•
2 years ago
Hello,
I am having trouble simply trying to load a XML file into the XMLElement object and am not sure what I am doing wrong.
My XML file is as follows:
- <?xml version="1.0"?>
- <index>
- <test1 id="1" name="one">test1</test1>
- <test2 id="2" name="two">test2</test2>
- <test3 id="3" name="three">test3</test3>
- </index>
And my code is simply:
- XMLElement xml;
- void setup() {
- size(200, 200);
- String xmlDoc = "xmlDoc.xml";
- xml = = new XMLElement(this, xmlDoc);
- }
This then gives a compile error:
Invalid input: `?' (0xfeff), SystemID='file:.', Line=1
at processing.xml.XMLUtil.errorInvalidInput(Unknown Source)
at processing.xml.StdXMLParser.scanData(Unknown Source)
at processing.xml.StdXMLParser.parse(Unknown Source)
at processing.xml.XMLElement.parseFromReader(Unknown Source)
at processing.xml.XMLElement.<init>(Unknown Source)
at xml_test.setup(xml_test.java:25)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
My xml file is saved next to the pde file in my sketchbook. I've tried putting the xml file in a folder called "data" but then it can't be found. As far as I can see, I'm doing exactly the same as in the XMLElement reference
http://processing.org/reference/XMLElement.html and I can't figure out what's going wrong.
Any help would be greatly appreciated! Thank you.
2