Re: [xml-dev] how to skip parsing of a subtree?

From
Anil Philip <>
To
"Steven J. DeRose" <>, xml dev <>
Date
2005-10-10T14:30:33Z
ID
<>
Thread
Re: [xml-dev] how to skip parsing of a subtree?
Thanks for replying.
I am ok with parsing up to it. How do you shut down
the parser? I see no shutdown/stop call in XMLReader.

This is the way I had planned to implement looking for
a node, but it will not stop the unnecessary parsing.
In startElement() at the very beginning:

 if (qualifiedName.equalsIgnoreCase("Node")) {
  if(!inRequiredSubtree) {
    if(idToLookFor == id)
      inRequiredSubtree = true;
    else {
         return;
    }
  }
...process
}

In endElement():
if (qualifiedName.equalsIgnoreCase("Node")) {
  if(id == idToLookFor) {
   inRequiredSubtree = false; 
   return;
  }
  if(inRequiredSubtree) {
...process
  }
}

thanks,
Anil

--- "Steven J. DeRose" <> wrote:

> At 06:46 -0700 2005-10-10, Anil Philip wrote:
> >Hello,
> 
> Skipping the part *after* the subtree you want is
> easy: just shut 
> down the parser.
> 
> Skipping the part *before* may be hard. If your tree
> is headed by
> 
>     <foo nodeID='65536'>...
> 


for good news go to http://members.tripod.com/~goodnewsforyou/goodnews.html


	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com