AssetManager documentation

If anyone stumbles upon this via a search engine, I fixed my problem.

XPath uses InputSources to parse expressions, but it can also use Document objects. You can use a loader like:
[java]
public class XMLLoader implements AssetLoader {

public Document load(AssetInfo assetInfo) {
    return createDocFromStream(assetInfo.openStream());
}

public static Document createDocFromStream(InputStream inputStream) {
    try {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        return builder.parse(inputStream);
    } catch (Exception ex) {
        return null;
    }
}

}
[/java]
to create a Document object from your XML file. You will need to call:
[java] assetManager.registerLoader(XMLLoader.class, “ext”) [/java]
to register your loader. You can then grab your XML file and evaluate XPath expressions the same way you would with an InputSource.

Thanks, @pspeed, for trying to help :slight_smile:

1 Like