Re: Basic XML::SAX question, including XML snippets
by Grant McLean other posts by this author
Jan 31 2005 6:43PM messages near this date
view in the new Beta List Site
Basic XML::SAX question, including XML snippets
|
Re: Alternative version of HTML::Tidy
& XSLT On Mon, 2005-01-31 at 19:31 -0500, Josh Narins wrote:
> I have a module which extends XML::SAX::Base. I want to replace an
> arbitrary tag (say, <storycontent />) with a longish, arbitrary string
> that contains XML.
>
> What do I do?
>
It's not rocket science, but there are a few things to watch out for...
In your start_element handler, when you detect the special tag you would
create a new SAX parser object that uses your object as its handler.
Then you would pass your arbitrary XML string to the new SAX parser
object.
You'll also need to intercept the end_element event for the special tag
so that downstream handlers don't get an end_element for which there was
no start_element.
It's also a good idea to intercept the start/end_document events for
your sub document so that the downstream handlers don't see them.
Kip Hampton had an article that touches on this:
http://www.xml.com/pub/a/2002/02/13/sax-machines.html?page=2
My comment at the bottom of the page relates to the extra
start/end_document events.
Regards
Grant
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Josh Narins
Grant McLean
|