in reply to P:RD and XML (minor code review)

I'm attempting to parse XML files with Parse::RecDescent

Gotta ask why!

Anyway, Perl can handle that with zero-width lookaheads.

CharData : /(?:(?!\]\]>)[^<&])*/ { XML::CharData->new($item[1]) }
or
CharData : /(?:(?!<|&|\]\]>).)*/ { XML::CharData->new($item[1]) }
or
CharData : /(?:[^<&\]]|\](?!\]>))*/ { XML::CharData->new($item[1]) }

Replies are listed 'Best First'.
Re^2: P:RD and XML (minor code review)
by glenhein (Initiate) on Feb 17, 2010 at 16:29 UTC

    Why, you ask? The short answer is for shits-n-giggles :-) I wanted to learn more about P::RD, and I wanted to study the finer details of the XML spec. I don't plan on using my XML parser for anything more than a learning exercise.

    Thanks for for suggestions. I've never played with the zero-width regular expressions. I'll have to experiment with them.

    BTW, I didn't mean to post as Anonymous. I thought I was logged in when I posted, by I guess I wasn't!