aspose file tools*
The moose likes XML and Related Technologies and the fly likes Go directly to a document section Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Go directly to a document section" Watch "Go directly to a document section" New topic
Author

Go directly to a document section

Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
Ok, I'm new to xml so maybe I don't use the adecuate words, but I hope I make myself clear. I have a large xml document which contains information about files, structured this way:
<FILE>
<NAME>File1></NAME>
<SIZE>5000</SIZE>
</FILE>
So I have thousands of files in this document, now I want to acces to one file, for example file1, which can be anywhere in the document. Is there a way to do this?? I know I can read the entire document until I find the file, but I'm asking for a more efficient way of doing it. Thanks for the help.
[ October 18, 2005: Message edited by: Emili Calonge ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18115
    
    8

Many XML technologies (e.g. DOM, XSLT) read the whole file in any case, before you can start looking for particular parts of it. And any solution you come up with is going to have to read at least the whole file down to the part you are looking for. So my suggestion would be to look for a solution that works for you. When you get more experience in XML then you will be able to recognize good and bad solutions.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
If all you need out of the XML document is the content of one <FILE> element, this is an ideal candidate for SAX processing. The reasons being:
1. You can abort reading the file after the target information has been found.
2. The memory requirements are much less than the DOM approach which always parses the entire file into memory.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Go directly to a document section
 
Similar Threads
JAXP Not Creating Nodes
How to Actually UpLoad ?
how to transit the parameter ?
FileSets, any way to order them?
Can't get Text value from ENCTYPE=multipart/form-data