Hi Peter,

I finally start understanding how XML::twig handlers work though it sounds a bit tricky to me at first because I didn't put much debug code to trace the execution of each important line.

Now I understand that XML:Twig still reads the whole document from top to bottom, but the thing is, it judges the current nodes by predefined handlers one by one, if it's <topic/>, it run topic subroutine, if it's <ExternalPage/>, it runs externalpage subroutine, their relationship is just connected by the hash in _topic_handler subroutine.

I have to say that I'm very lucky because the document keeps a very well defined order of <topic/> and <ExternalPage/> and you wrote a good sample for me to understand how xml:twig works.

The last question about my approach is, I found a good place to close an opened file handler, it's just the first line in sub _topic_handler, however, how can I write some if statement to say, if FH is opened, then close it?

Thanks in deeply,

Nan

From: Peter Rabbitson <[EMAIL PROTECTED]>
To: beginners@perl.org
Subject: Re: Errors on processing 2GB XML file by using XML:Simple
Date: Wed, 18 May 2005 09:06:33 -0500

> I know the answer of second question after reading a quick reference of
> twig...

You know the answer to your first question as well - you've been looking at
it the whole day :)

> >I have examined the XML file and all <Topic/>with <link/> children are
> >followed by their own <ExternalPage/>s. If there is a <Topic/> without
> ><link/> inside, it is followed by a new <Topic/>.

You wrote this paragraph yourself. Doesn't this sound like natural
interleaving?

> >codes, I found that the execute order of these two subroutines is:
> >
> ><Topic/> -> if no <link/> child, go to the next <Topic/> -> if there is
> ><link/> child, go to its following <ExternalPage/> -> until there is no
> >more <Topic/> nodes. I don't know that which part of codes control this
> >order, is it because of the order of two handlers you set in twig_handlers
> >which indicates the twig process should be interleaving?


Once again - you first wrote the answer, then wrote the question to it. Read
it again (and again if it's necessary :)


Peter


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>





-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to