| | 1 | = XML-Loader = |
| | 2 | |
| | 3 | The goal of the XML-Loader is to import levels defined in an XML-File into the game engine. This is done by parsing a specified XML-File and adding all defined Entities for the Scene-Manager. |
| | 4 | |
| | 5 | == XML-Design == |
| | 6 | |
| | 7 | See [wiki:LevelHowTo] (don't know if this is still up to date...) |
| | 8 | |
| | 9 | == Ticket == |
| | 10 | |
| | 11 | This page referrers to [http://www.orxonox.net/ticket/232 Ticket 232] which is maintained by [http://www.orxonox.net/wiki/NicolasPerrenoud Nicolas Perrenoud] |
| | 12 | |
| | 13 | == Library == |
| | 14 | |
| | 15 | I'm using the [http://iridia.ulb.ac.be/~fvandenb/tools/xmlParser.html xmlParser] Library from Frank Vanden Berghen which is small, simple to use and fast. ([http://www.applied-mathematics.net/download.php?id=43 Download]). |
| | 16 | It uses only one class, which is defined in xmlParser.cpp, xmlParser.h |
| | 17 | The class '''XMLNode''' reflects an Node in the XML-File. It has methods to get the child nodes, get the attributes and inner text. |
| | 18 | |
| | 19 | '''Example:''' |
| | 20 | |
| | 21 | <root> |
| | 22 | <level name="Argon Prime"> |
| | 23 | Lorem Ipsum dolor sit amet |
| | 24 | </level> |
| | 25 | </root> |
| | 26 | |
| | 27 | '''XMLNode xMainNode=XMLNode::openFileHelper("level.xml","root");''' // This loads the xml file and defines root as the main node |
| | 28 | |
| | 29 | '''XMLNode xNode=xMainNode.getChildNode("level");''' // This creates a new node object of child node <level> |
| | 30 | |
| | 31 | '''cout << xNode.getAttribute("name");''' // This prints the value xNode's attribute name, in this case ''Argon Prime'' |
| | 32 | |
| | 33 | '''cout << xNode.getText());''' // This prints the inner content of xNode, in this case ''Lorem Ipsum dolor sit amet'' |
| | 34 | |
| | 35 | == Misc == |
| | 36 | |
| | 37 | See [wiki:archive/XML-Writer] for an XML-Writer description |
| | 38 | |
| | 39 | |