title: Roll your own XML parser / XML parsing algorithm?
body: <p>So, just as a fun project, I decided I'd write my own XML parser. No, not to parse a specific document, and no, not using an XML parser library. I mean writing code to parse out any XML document into a usable data structure. Just because I like the challenge. :-)</p>
  
  <p>With that said, so far it's proved to be... interesting. It's not as easy to parse (especially when you start taking into account special characters, CDATA, empty tags, comments, etc.) as it initially looked. </p>
  
  <p>Are there any well documented XML parsing algorithms or explanations anywhere that anyone knows of? It seems like there are well-documented Queue and Stack and BTree and etc. etc. etc. implementations everywhere, but I'm not sure I've ever seen a simple, well-documented XML parser algorithm...</p>
  
  <p><strong>I repeat:</strong> I am <strong>not</strong> looking for a pre-built parser library! I am looking for information on <strong>how to create my own pre-built parser library</strong>! Do not tell me "use expat" or "use SAX" or whatever. That's not what I'm asking for.</p>