how to parse an xml file
I need to parse an XML file hello.xml which is in WEB-INF/classes folder
My Action class calls a helper class called XMLMenuBuilder which needs to parse the menu.xml
XMLMenuBuilder builder = new XMLMenuBuilder();
Vector menuV = (Vector)builder.renderMenu();
public Vector renderMenu() throws AppException
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse( new File(xmlfile) );
My Problem is how can I make the builder.parse access the menu.xml file under the WEB-INF/classes folder instead of searching for it on the file system
If you are using .war file and it has WEB-INF/classes folder and also your class files...then you can use xmlfile = "WEB-INF/classes/menu.xml"
Because the file is in your classes folder you can use the ClassLoader to get at it. Try this:
That will get you what you want.
it worked brianhks
thanks to everybody