2 ms·
I found a one-pass top-down "XML parser". Not like a proper SAX parser, no... the XML had to be specially formatted, almost like TOML. <whatever> <--- Pars
by dragontamer 6y ago
I found a one-pass top-down "XML parser". Not like a proper SAX parser, no... the XML had to be specially formatted, almost like TOML.
<whatever> <--- Parser parsed this as a new section
<foo attrib=bar> <--- All "XML" had to be one-per-line
</whatever> <---- parser ignored this
It was an "XML parser" per se, but it really was just a linear one-pass parser that tricked me into thinking it was XML.
So really, it was more like TOML (or .INI files) than like XML. But I guess the advantage of making it "bastard XML" instead of TOML is that maybe this worked with XML-editors or something. I dunno...
- cbsks 6y agoI’ve written an XML parser like this for a toy project. I passed the XML through a prettifier first so that it was in a standard format. It wouldn’t work for every XML file, but it worked on the files that I needed it for. I have also had success searching through html files with grep after passing them through a prettifier. It’s ugly, but 90% of the time, it works every time!
- dragontamer 6y agoThe specific project I saw that did this had ALL of its configuration files in this "Bastard XML" format. Its ugly, but when 100% of your files you interpret match the one-per-line (and other clearly made-up rules), then it works 100% of the time!!