Load Custom Xml data

Hello everyone

Can’t find example of loading custom xml data.

Here is what i’m trying to create:
Load list of configurations and resources xml files from <assets>/Xml/resources.xml. Then load the data from the files described therein

Also there is no hint about the need of closing InputStream from assetInfo. Whether to close the InputStream after reading the xml file ?
The Search gives only results about loading models from xml

Also question: InputStream from AssetInfo is BufferedInputStream or just InputStream ?

Why do you care? for most of all usecases just lading the xml from an inputstream will do. If its very slow try with a bufferd wrapped around.

I would close it. As you opendend it, it should be your responsibility.

@Empire Phoenix said: Why do you care? for most of all usecases just lading the xml from an inputstream will do. If its very slow try with a bufferd wrapped around.

I would close it. As you opendend it, it should be your responsibility.


that’s not the answer.

If short, the question is: how to load custom xml file using AssetManager ? Please provide some example.

For my own game, I implemented an asset loader for XML files, based on DOM and Sax. The code is available here.

1 Like

As a result, i wrote it here

[java]
assetManager.registerLoader( XmlLoader.class, “xml” );
[/java]
XmlLoader implements AssetLoader

1 Like

That’s right. And then when you want to load the asset, you invoke com.jme3.asset.AssetManager.loadAsset(assetPath); and cast the result to a Document,
like I do in line 572 of Assets.java.

1 Like