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 file path in XML 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 "file path in XML" Watch "file path in XML" New topic
Author

file path in XML

Yell Srik
Ranch Hand

Joined: Mar 10, 2004
Posts: 61
Hi,
i need clarification regarding XML and file paths:
i have an XML as shown:

<contents>
<desc>C:\My Documents\abc.txt</desc>
<fig>C:\My Documents\ab.jpg</fig>
</contents>

(1)i generated the above tags using javascript. can i say that the above is a valid XML file.
(2) how is possible to extract the file from the file path mentioned in the XML tags ie i want my server side program(either a servlet or JSP) to extract the "abc.txt" file specified in the above XML. how can it be done?
thanks in advance.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
can i say that the above is a valid XML file
Yes. It's a well-formed XML document.

how is possible to extract the file from the file path mentioned in the XML tags ie i want my server side program(either a servlet or JSP) to extract the "abc.txt" file specified in the above XML. how can it be done?
By extracting the file path using the DOM API, for example (or SAX, or XPath, or whatever you're using for parsing the XML document in the first place), and then using java.io.* for reading the file from wherever the file path points to.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: file path in XML
 
Similar Threads
is this XML???
extracting data using servlets
using JSP to read from js window
generating XML using servlets/jsp
servlets and XML