* @throws SlickException Indicates a failure
*/
public static void main(String[] argv) throws SlickException {
XMLParser parser = new XMLParser();
XMLElement root = parser.parse("testdata/test.xml");
assertEquals(root.getName(), "testRoot");
System.out.println(root);
assertNotNull(root.getChildrenByName("simple").get(0).getContent());
System.out.println(root.getChildrenByName("simple").get(0).getContent());
XMLElement parent = root.getChildrenByName("parent").get(0);
assertEquals(parent.getChildrenByName("grandchild").size(),0);
assertEquals(parent.getChildrenByName("child").size(),2);
assertEquals(parent.getChildrenByName("child").get(0).getChildren().size(),2);
XMLElement child = parent.getChildrenByName("child").get(0).getChildren().get(0);
String name = child.getAttribute("name");
String test = child.getAttribute("nothere","defaultValue");
int age = child.getIntAttribute("age");
assertEquals(name, "bob");
assertEquals(test, "defaultValue");
assertEquals(age, 1);
XMLElement other = root.getChildrenByName("other").get(0);
float x = (float) other.getDoubleAttribute("x");
float y = (float) other.getDoubleAttribute("y", 1.0f);
float z = (float) other.getDoubleAttribute("z", 83.0f);
assertEquals(x, 5.3f);
assertEquals(y, 5.4f);
assertEquals(z, 83.0f);
try {
z = (float) other.getDoubleAttribute("z");
fail("Attribute z as a double should fail");
} catch (SlickException e) {
// expect exception
}
}