Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-19-2007, 01:00 AM
Member
 
Join Date: Jul 2007
Posts: 41
oregon is on a distinguished road
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

the code:

LogonAction.java
Code:
XMLMenuBuilder builder = new XMLMenuBuilder(); Vector menuV = (Vector)builder.renderMenu();
XMLMenuBuilder.java
Code:
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
any ideas?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-19-2007, 03:04 PM
Member
 
Join Date: Jul 2007
Posts: 17
sathish_2111 is on a distinguished road
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"
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-31-2007, 01:03 AM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
Because the file is in your classes folder you can use the ClassLoader to get at it. Try this:
Code:
builder.parse(this.getClass().getClassLoader().getResourceAsStream(xmlFile));
That will get you what you want.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-01-2007, 05:53 PM
Member
 
Join Date: Jul 2007
Posts: 41
oregon is on a distinguished road
it worked brianhks
thanks to everybody
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Parse int to a string variable raj reddy Java Servlet 4 06-27-2008 12:58 PM
SAX Parse bluefloyd8 New To Java 1 01-25-2008 04:57 PM
How to parse in html paty New To Java 1 07-24-2007 01:29 AM
Parse error Eric Advanced Java 2 07-01-2007 07:32 PM
How to parse HTML tags Ada Advanced Java 1 05-31-2007 10:42 PM


All times are GMT +3. The time now is 02:58 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org