Developers, Developers, Developers! Maksim Sorokin IT Blog


Reading XML File in Custom IzPack Panel

Sometimes it is needed to have some configuration file in your custom IzPack panels. It is easy to have one!

First, you have to reference your configuration file from resources section in install.xml file:

  <res id="mySpec.xml" src="mySpec.xml" />

Then you would need to create such file in your IzPack resources.

And then you can read your file from your custom panel:

public void panelActivate() {
  InputStream is = ResourceManager.getInstance().getInputStream("mySpec.xml");

Moreover, you can read xml using IzPack capabilities. Not that convenient, but anyway:

    String xml = inputStreamToString(is);    // I omit this peace of code, since it is not relevant. "is" -- is InputStream

    IXMLParser parser = new XMLParser();
    IXMLElement rootEl = parser.parse(xml);

    Vector<IXMLElement> els = rootEl.getChildrenNamed("myElements");
    Iterator<IXMLElement> it = els.iterator();
    while (it.hasNext()) {
      IXMLElement el =;

      String myAttribute = el.getAttribute("myAttribute");
Comments (2) Trackbacks (0)

Leave a comment

Trackbacks are disabled.