2017-04-18 12:39:29 +02:00
# About XMLExample
2016-02-18 17:44:16 -07:00

2017-04-18 12:39:29 +02:00
### Learning Objectives
2016-02-18 17:44:16 -07:00
2016-02-18 20:03:27 -07:00
This example demonstrates how to read and write an xml file to the file system leveraging ```ofXML` ``.
2016-02-18 17:44:16 -07:00
In the code, pay attention to:
2016-02-18 20:03:27 -07:00
* Use ` ``ofXML` `` to read an xml file from the file system with ` ``XML.load("mySettings.xml")` ``
2016-02-18 20:05:06 -07:00
* Writing an xml file to the file system with ` ``XML.save("mySettings.xml")` ``
2016-02-18 17:44:16 -07:00
2016-02-18 20:03:27 -07:00
* Adding childNodes to the xml with ` ``XML.addChild` `` and appending with ` ``XML.addXML` ``
* Parsing and traversing XML with ` ``XML.exists()` ``, ` ``XML.getValue()` ``, ` ``XML.setToSibling()` ``,` ``XML.setToParent()` ``, ` ``XML.setTo()` ``,` ``XML.getName()` ``
2016-02-18 17:44:16 -07:00
### Expected Behavior
When launching this app for the first time, you will see a screen with:
* A black background, with a thin column on the left and a large filled rect on the right
* Text instructions at the top and at the bottom of the screen.
* A line drawn on the right canvas
When the mouse is pressed, the application :
* starts to record the drag movement.
* As the mouse is dragged across the canvas, the path is drawn in a thin stroke to the canvas.
* The background will changing color randomly with mouse movement
* Drag coordinates, along with the background color are captured in an xml structure while dragging
2016-02-18 20:03:27 -07:00
When the key ` ``s` `` is pressed:
2016-02-18 17:44:16 -07:00
2016-02-18 20:03:27 -07:00
* The application will save the stored xml data structure into the ` ``data\mySetttings.xml` `` file.
2016-02-18 17:44:16 -07:00
Instructions for use:
* Press down on the canvas with the mouse and start dragging the mouse while holding down.
2016-02-18 20:03:27 -07:00
* Press ` ``s` `` to save the xml file of the current state to a local xml file
2016-02-18 17:44:16 -07:00
* Restart the application to see the saved settings of the last drawn recording restored.
2017-04-18 12:39:29 +02:00
### Other classes used in this file
2016-02-18 17:44:16 -07:00
This Example uses no other classes.