NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
XML Regexes (Score:2)
A very good list of truisms. However, there is the subtlest of subtle flaws in this list -- all categorical statements (including this one) are false. For example:
Sometimes you do want to parse XML with regexes, but only in the most controlled of circumstances. Usually this involves munging huge quantities of data that are very rigidly formatted. If you can fully control the structure of XML inputs, and you tend to be reading inputs line-by-line (or bloc
Re:XML Regexes (Score:1)
There is a paper, http://www.cs.sfu.ca/~cameron/REX.html [cs.sfu.ca], which develops the regex for parsing XML.
Re:XML Regexes (Score:1)
Note that those patterns parse simple XML, not XML with namespaces. Parsing XML with namespaces purely using pattern matching is probably possible too, but it’d be a whole hell of a lot harder, and the patterns would be nasty monstrosities far more so than the managable beasts from that paper.
Re:XML Regexes (Score:1)
I suspect they aren't suitable for doing interesting operations. They could be used for stuff that works on the chunks, like removing comments.
Reply to This
Parent
Re:XML Regexes (Score:1)
Well, or building a full-fledged parser on top. That’s not a very large step from there.