Re: [xml-dev] Parsing XML with anything but

From
Pete Cordell <>
To
, Amelia A Lewis <>
Date
2013-12-10T11:26:47
ID
<76E0697F23E844D59CCEA610AC10D1B2@codalogic>
Thread
Re: [xml-dev] Parsing XML with anything but
Original Message From: "Liam R E Quin" <>
> On Mon, 2013-12-09 at 23:10 -0500, Amelia A Lewis wrote:
>> Hey, Liam!
>>
>> On Mon, 09 Dec 2013 22:07:09 -0500, Liam R E Quin wrote:
>> > The "desperate perl hacker" was a significant and much-discussed use
>> > case during XML development, and was part of why we chose a 
>> > self-evident
>> > empty element syntax.
>>
>> Mmmmm. I suggest that you didn't succeed. XML, in the general case,
>> cannot be reliably handled with regular expressions.
>
> But I didn't say that I wrote a parser or that I handled the general
> case.
>
> (you can, by the way, use Perl's extended regular expressions to parse
> XML reliably, because they can handle nesting correctly, but that's
> another matter and not what I'm doing).


And there's a difference between trying to come up with a single regular 
expression for XML, and using Perl's incremental matching of strings (using 
the /gc flag) to do 'low-level' tokenisation and glue a bunch of regexs 
together using higher level code.  (Although that most likely just moves it 
into the possible, but pointless category as Perl already has XML parser 
libraries if your problem needs that generality.)

Pete Cordell
Codalogic Ltd
C++ tools for C++ programmers, http://codalogic.com
Read & write XML in C++, http://www.xml2cpp.com