• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file path in XML

 
Yell Srik
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic