Subject: Optimizing search in a xml document
Posted By: roy Post Date: 9/22/2003 6:10:38 PM
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

Reply By: pgtips Reply Date: 9/23/2003 4:28:22 AM
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']")
Reply By: roy Reply Date: 9/23/2003 5:17:09 PM
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



Go to topic 4464

Return to index page 1040
Return to index page 1039
Return to index page 1038
Return to index page 1037
Return to index page 1036
Return to index page 1035
Return to index page 1034
Return to index page 1033
Return to index page 1032
Return to index page 1031