This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
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://aspose.com/file-tools
 
subject: file path in XML