Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 22nd, 2003, 06:10 PM
roy roy is offline
Registered User
 
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Optimizing search in a xml document

Hi.
If I want to use indexed search on a xml document, using DOM, can xml schema help me to do so?

BUT, an additional requirment is, that this it can have duplicate values( I mean, have the same value, in different elements)

For example,
<root>
  <a id='1' ExAtt='1'/>
  <a id='2' ExAtt='2'/>
  <a id='3' ExAtt='2'/>
  <a id='4' ExAtt='1'/>
</root>


If I want to get, using DOM, all the nodes that have the value '1' for the 'ExAtt' attribute. can I optimize this search ?
( make this attribute indexed somehow)

Thanks a lot
Roy
 
Old September 23rd, 2003, 04:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

I don't know of any way to index a document - XPath is probably your best bet:
Set xNodeList = xDomDocument.selectNodes("/root/a[@ExAtt='1']")
 
Old September 23rd, 2003, 05:17 PM
roy roy is offline
Registered User
 
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by pgtips
 I don't know of any way to index a document - XPath is probably your best bet:
Set xNodeList = xDomDocument.selectNodes("/root/a[@ExAtt='1']")

I tried to use it once - but iit is very very slow.
Finding un-indexed node is very slow, aspecially on a big tree.

One solution by Oleg Tkachenko is :
DOM doesn't provide any functionality to optimize such kind of operations. As
it's not unique it cannot be ID. The only way is to walk through the whole
tree and create a hashtable of such nodes - next time you can use the
hashtable to get nodes directly by key.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel







Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Get XML Document from iFrame rvanandel Ajax 6 April 10th, 2009 05:24 AM
search document about ws security delymed XML 0 October 19th, 2004 02:55 AM
xml document androger XML 2 November 19th, 2003 05:52 PM
XML Document Problem Ben Horne XML 5 November 19th, 2003 01:49 PM
Writing an XML document Ben Horne XML 4 November 13th, 2003 12:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.