JM§: how to import XML files for further processing

I have tile-sets that define the textures in my application. every tileset has an xml-file that describes the set, for example:


<tileset name=“default”>

<author name=".rhavin grobert" />

<application name="…" />


<image id="_WINDOWBACK" ref=“windowback.gif” flags=“wall, edge, system, texture” name=“dark bricks” />

<image id="_STDDNGNWALL" ref=“stdwall.jpg” flags=“wall, edge, paintable, texture” name=“natural boulderwall” />

<image id="_STDDNGNFLOOR" ref=“stdfloor.jpg” flags=“wall, edge, paintable, texture” name=“cobblefloor” />

<image id="_STDDNGNCEIL" ref=“stdceil.jpg” flags=“wall, edge, paintable, texture” name=“dirty ceiling” />

<image id="_STDDNGNWOOD" ref=“wooddk.gif” flags=“wall, edge, paintable, texture” name=“dark wood” />

<image id="_STDDNGNGLASS" ref=“glass.png” flags=“wall, edge, paintable, texture” name=“glass” />

<image id="_EDITDIGG" ref=“icn_shovel.png” flags=“system” name=“digg” />

<image id="_EDITEDGE" ref=“icn_pillar.png” flags=“system” name=“edge” />

<image id="_EDITWALL" ref=“icn_wall.png” flags=“system” name=“wall” />

<image id="_EDITFILL" ref=“icn_filling.png” flags=“system” name=“filling” />

<image id="_EDITPAINT" ref=“icn_painting.png” flags=“system” name=“painting” />

<image id="_ICNOK" ref=“icn_ok.png” flags=“system” name=“ok” />

<image id="_ICNCANCEL" ref=“icn_cancel.png” flags=“system” name=“cancel” />

<image id="_ICNINSERT" ref=“icn_insert.png” flags=“system” name=“insert” />

<image id="_ICNPROPS" ref=“icn_props.png” flags=“system” name=“properties” />

<image id="_ICNLEVEL" ref=“icn_level.png” flags=“system” name=“level” />

<image id="_ICNPLANE" ref=“icn_plane.png” flags=“system” name=“plane” />

<image id=“BRICKWALL” ref=“greybrick.jpg” flags=“wall, edge, paintable, texture” name=“bricks” />

<image id=“SANDBLOCKS” ref=“sandblocks.jpg” flags=“wall, edge, texture” name=“sandblocks” />

<image id=“SANDBRICKS” ref=“sandbricks.jpg” flags=“wall, edge, texture” name=“sandbricks” />

<image id=“SANDSTONE” ref=“sandstone.jpg” flags=“wall, edge, texture” name=“sandstone” />

<image id=“WOOD” ref=“wood.gif” flags=“wall, edge, texture” name=“wood” />

<image id=“PAINTBLOOD1” ref=“bloodsplash1.png” flags=“overlay” name=“bloodsplash1” />

<image id=“PAINTBLOOD2” ref=“bloodsplash2.png” flags=“overlay” name=“bloodsplash2” />




now i want to parse that file, and i’d like to do that with the assetManager, because it should afterwards be responsible for loading those textures, as it seems to already have xml-functionallity.

How do i set up an xmlloader that does not get in the way of the OgreXML loader?

Use a different suffix for these xml files.

you mean, like *.tileset.xml or you mean i should not use the extension xml for an xml-file?

Are you asking how do you read an XML file and store its content into your custom data structure? If so I can post a quick example, if not please elaborate.

You should use just another extension like .tileset Personally I find it silly that so many xml files out there have the xml ending, its like naming all binary files .bin :confused:

normen said:
You should use just another extension like .tileset Personally I find it silly that so many xml files out there have the xml ending, its like naming all binary files .bin :/

The one key feature of keeping the extension .xml is it is beautiful for the lazy man. If I name it .tileset then I have to dig into the options of my editor to get it to read .tileset like a xml file for the pretty colors and collapsing feature. If I use more than 1 editor I have to do it in multiple places. Keeping .xml is for the lazy man ;)

Ever heard of mime types to determine filetypes? ^^ Windows is the only OS that never understood them :stuck_out_tongue:

haha I forgot about that. Then again I do use windows. I downloaded alpha 4 last night its nice. Waiting on beta before I turn my Proof of Concept into an actual game. Changes like the physics from a node to a control would of been rough if I was far along in my project.

scrubalub said:
Changes like the physics from a node to a control would of been rough if I was far along in my project.

Thats why I did it as soon as possible


Is this the method of choice for loading files/be all end all? I didn’t even think of doing it this way and I’m just building a small loader on scene creation that just parses xml files for the more nitty-gritty things about the scene/actors, referenced by object names.

Got me thinking now… T_T!


Yeah, because its managed properly :stuck_out_tongue: AssetManager needs absolute paths and thus maintains a root for itself. The game should not be dependent on being run in one folder or the other… If its data thats not directly related to the engine ofc you can load via File or something but you will end up in a situation where you have multiple ways to access files that will or will not work together in different situations (and have to be updated separately).

Hello again!

:insert mega-sadface here: :cry:

Ah well. I’ll go play with this when I get the chance. At least, as you said, I won’t have to deal with problems locating the assets because of file pathing issues. I guess it shouldn’t be too hard to adapt because I’m already working with xml files. I think I’m using the DOM parser though and not the SAX one that I think I spotted on quick investigation. I’ll go prod the code and the tutorials for more info on building a loader :stuck_out_tongue:

Sorry for the slight thread hijack.


As said, its not “disallowed” but the engine has a pretty cool economy, so its worth investing in it :wink:

guys, an xml-file is xml-extended because it is xml-format. the premium-solution would be selecting loader by xml-root-tag. Also acceptible would be a mechanism where you could specify a certain loader for a certain file, like

[java]loadAsset(String file, AssetLoader loader)[/java]

but you cant seriously hardwire xml-extension to orge-meshes.

dude, a binary file has no .bin ending because its just data, as an xml file is too. All word processors use xml content now and we don’t have doc.xml because of that… But in fact the ogre model loader should only react to mesh.xml skeleton.xml and the way its scanning for the double endings is a bit hacked… Did you actually try it?

I’m for the .bytearray extendsion for ALL files no more conflicts anymore ^^

No seriously just because it conatins xml ou don’t have to extend it with .xml

I’ll do when i return tonight. What about

[java]loadAsset(String file, AssetLoader loader)[/java]

i still think its a nice idea…

You misunderstand the AssetManager, its like a classpath for data and it has to be able to handle AssetKeys on its own. Any transient info you would have in AssetLoader in your example would belong to an AssetKey. We in fact depend on the ending to identify an asset in the path because the identification works via the path String, but its not really a file-dependent thing. If you cant live without an “xml” in your filename, what about myFile.xml.type? :stuck_out_tongue:

Would it be possible to make it so longest match win?


So if one asset type use extension .xml, other can use .tileset.xml and still keep lazymans xml extension.

Hello again!

I know you guys probably don’t want to hear this, but this seems like a fantastic thing for an advanced tutorial. I mean, everyone is likely to have something they need to load that is custom for a project of reasonable size. I haven’t had a chance to dive into this yet so I don’t really know if it’s something complex or not, but I didn’t see anything on writing custom assetLoaders in the tutorials.

AssetLoaders, AssetKeys, AssetManagers oh my! :stuck_out_tongue: