Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Soulstorm

macrumors 68000
Original poster
Feb 1, 2005
1,887
1
I want to build a simple XML parser using C++. At first, I don't mind about DTD declarations or special features. I want to be able to load an XML string and then output the code in a simple tree holding strings (the values of the XML document)

But the problem is that although I know all about XML, I haven't got the slightest idea about how to make an XML parser (or any other parser of the same logic). I believe a recursive descent parser is sufficient.

Can anyone point me into the right direction? All I want is a general idea, like the way I will organize my classes, what STL classes would prove useful... A general documentation upon parsers would also be helpful (google should work, but I always find better answers in forums).
 
Do you want to make a DOM-style parser (where you build a tree of nodes representing the XML document), or an event-driven parser (like the NSXMLParser stuff I saw you posting about recently)?

An event driven parser is probably the best place to start because it is a good first step in building a DOM-style parser anyway.

Edit: by the way, I've been wanting to implement some kind of XML parser, too, for educational purposes. I've got no good reason to do so, though. So, I've just been thinking about it. At work I've been using MSXML (one of Microsoft's XML libraries) a lot lately which has gotten me thinking a lot about it lately).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.