This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Parse XML file that is in a JAR file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Parse XML file that is in a JAR file" Watch "Parse XML file that is in a JAR file" New topic
Author

Parse XML file that is in a JAR file

Rob Bass
Ranch Hand

Joined: Aug 28, 2001
Posts: 67
Hello,
I need to parse an XML file that is in a JAR file. All i have is a path to the jar file, is there a way to access the xml file without unjaring the file?
Let me know,
Rob
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
obviously The jar file needs to be in the classpath. Then it can be accessed through one
helper methods like this one..
Class c = this.getClass();
URL fileURL = c.getClassLoader().getResource("filename");
check the documentation.
HTH
Rob Bass
Ranch Hand

Joined: Aug 28, 2001
Posts: 67
You are using this.class. I cannot use that. I am providing a service to read\parse xml files. All they will pass me is the location of the jar file.
With just the location of the jar file can I access the xml file contained within
Mathew Kuruvilla
Ranch Hand

Joined: Nov 27, 2001
Posts: 135
Try using the methods in Class java.util.zip.ZipFile.
Also executing 'jar tf class12.jar' will send all the contents of the class12 to the standard output. Hope this helps.
Mathew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parse XML file that is in a JAR file
 
Similar Threads
XMLBeans parsing question
NoClassDefFoundError: org/dom4j/io/SAXReader
javax.xml.parsers error
Xml Parsing
Parsing a DOM object