XmlElementParts parts(&toker); while(parts.get()) { if(parts[0] == "<") // isn't text node { if(parts[1] == "?") { // make XmlNode // store processing instruction under document node continue; } if(parts[1] == "!") { // make XmlNode - just stores text of comment // store comment as child of top node on stack continue; } if(parts[1] == "/") { // end of element so pop node stack continue; } // make XmlNode with names and attributes // this is a new element so push onto node stack continue; } // make XmlNode with text // this is a text node so store as child of top node on stack }