eXML
[General Eiffel Badge]
[General Eiffel Badge]
[General Eiffel Badge]
The Tree Based Parser

For the user of the library in most cases the tree based parser will be the better choice. For this reason I will limit the documentation on this topic for now. Objects of the type XML_TREE_PARSER can be feed with a XML document split up in one or more strings. The following example parsers a XML document that is stored completly in a string object of the name `buffer'.

	.
	.
	.
	local
		parser: XML_TREE_PARSER
	.
	.
	.
			-- somewhere the parser must be created (:
		!! parser.make
	.
	.
	.
			-- parse the XML-document
	parser.parse_string (buffer)
			-- and tell the parser that the end of the document has been reached
	parser.set_end_of_file	
	
	if
		not parser.is_correct
	then
			-- whoops! there was an error in the docment.
			-- print out some information about that error
		print ("%N")
		print (parser.last_error_string)
		print (" at ln: ")
		print (parser.last_line_number)
		print (", cl: ")
		print (parser.last_column_number)
		print ("%N")
	else
			-- the document was parsed successfully.
			-- print out the structure of the document
		print (parser.out)
	end
	
	

The parser stores the information contained in the XML-document as a tree consisting of XML_NODES. The following is a inheritance graph of all nodes currently implemented.

nodes

The parser inheritance graph itself is presented in the next picture. You see that the tree parser not only inherits from the event based parser, but also from XML_DOCUMENT. Objects of the type XML_DOCUMENT represent a whole XML-document. They have a `root_element' of the type XML_ELEMENT and (in the future will) hold additional information given in the XML-document (i.e. the encoding)

parser