Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Go directly to a document section

 
Emili Calonge
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20949
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic