You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers. No questions about C++ programming or topics which are answered in the tutorials!
<?xml version="1.0"?>
<config>
<!-- This is a config file for the mesh viewer -->
<models>
<model file="dwarf.dea" />
<model file="dwarf1.dea" />
<model file="dwarf2.dea" />
</models>
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
<config>
<!-- This is a config file for the mesh viewer -->
<models>
<model file="dwarf.dea" />
</models>
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
<config>
<!-- This is a config file for the mesh viewer -->
<models>
<model file="dwarf.dea" />
</models>
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
Getting all config-elements is not that difficult, but how do I get i.e. all model-elements from the first config-element or all model-elements from all config-elements?
I've already used tinyXML for parsing XML and with that lib you can access directly all child elements of an parent element.
(i.e. give me all model(s) of the first config)
<config>
<!-- This is a config file for the mesh viewer -->
<models>
<model file="dwarf.dea" />
<model file="dwarf1.dea" />
<model file="dwarf2.dea" />
</models>
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
<config>
<!-- This is a config file for the mesh viewer -->
<models>
<model file="dwarf.dea" />
</models>
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
<config>
<!-- This is a config file for the mesh viewer -->
<models>
<model file="dwarf.dea" />
</models>
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
the MeshViewer example in the irr SDK has an ok example of how to parse XML files and I should think that IrrXML provides some more complex samples too, have you looked at any of those?
@geckoman
You are right ...
Actually there is a root element in my live-project. For this post I used an extended version of the tutorial example from the irrXML page. http://www.ambiera.com/irrxml/index.html
@JP
Thx for the tip looking into the examples I didnt do that yet ... I will reply
if this example covers what I am looking for.
Okay I've checked the MeshViewer example, unfortunately this example only uses the easy case of reading XML files with only one element per tag like in the example of the irrXML tutorial.
Originally I didn't like IrrXml, but that was simply because I didn't understand it. Once I read the loadScene function in CSceneManager.cpp IrrXml made perfect sense and I'm quite fond of it now. Just read that function (and the sub functions it calls) and everything will make sense.
// read materials from attribute list
io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver);
attr->read(reader);
is used to get the child elements of the parent element. (I'm guessing here)
Is this right and is this the only way to get only the children of the parent node(element) and not all elements with the same node name?
Those methods only load IAttributes, which are Irrlicht's way of holding values for serializable types. They don't really have much to do with the XML reader or writer, and they can't have duplicate keys.
IrrXML just reads the file sequentially, you call read() to advance one node, followed by getNodeType then call the other methods to extract the data.
In your example you'd have a EXN_ELEMENT node named "config", then a EXN_COMMENT, followed by an EXN_ELEMENT node named models, an EXN_ELEMENT named "model" with an attribute count of 1, with the name "file" and the data "dwarf.dea", then a EXN_ELEMENT_END ( the "/>" ), then another EXN_ELEMENT node named "model" and so on. Parsing this would be as trivial as the meshviewer example.
<?xml version="1.0"?>
<root>
<config>
<!-- This is a config file for the mesh viewer -->
<models>
<model file="dwarf.dea" />
<model file="dwarf1.dea" />
<model file="dwarf2.dea" />
</models>
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
<config>
<!-- This is a config file for the mesh viewer -->
<models>
<model file="dwarf.dea" />
</models>
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
<config>
<!-- This is a config file for the mesh viewer -->
<models>
<model file="dwarf.dea" />
</models>
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
</root>