1Mar/11Off
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:
<resources> <res id="mySpec.xml" src="mySpec.xml" /> </resources>
Then you would need to create such file in your IzPack resources.
And then you can read your file from your custom panel:
@Override
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 = it.next();
String myAttribute = el.getAttribute("myAttribute");
...
March 1st, 2011 - 15:30
Thanks for your posts on IzPack!
I have added a short news at http://docs.codehaus.org/display/IZPACK/2011/03/01/Good+blog+posts+on+IzPack
March 1st, 2011 - 17:12
Thanks for the nice product! =)