The start of the CDATA section triggers the CdataStart handler, the end the CdataEnd handler, and the content is caught by the Char handler. So all you need is to set a flag when the CDATA section starts, then capture characters while the flag is set, then unset the flag at the end of the section.
Now for some unwanted advice:
- CDATA sections are just syntactic sugar, a shortcut to avoid escaping too many >'s and &'s. They are never garanteed to be there, you just cannot enforce it. So relying on a CDATA section being present is a little dangerous.
- If you are just starting with a project, you probably shouldn't be using XML::Parser. It is an old module, and its API is not standard at all. If you can install it, XML::LibXML is most likely a better choice: it is faster and way, WAY more powerful. Or of course XML::Twig ;--)
| [reply] |
Hey, Im really not sure about XML Parsers... but while surfing thru the net, I just got this The next question also gave a hint of how to "grab" the character data.
Hope they were of some use!
Did you ever notice that when you blow in a dog's face, it gets mad at you but when you take him on a car ride,he sticks his head out the window and likes it? | [reply] |