test cases in progress
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index a11be4b..5e1b1d8 100644
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -143,16 +143,22 @@
 	static const char* commentHeader	= { "<!--" };

 	static const char* dtdHeader		= { "<!" };

 	static const char* cdataHeader		= { "<![CDATA[" };

+	static const char* elementHeader	= { "<" };	// and a header for everything else; check last.

 

 	static const int xmlHeaderLen		= 5;

 	static const int commentHeaderLen	= 4;

 	static const int dtdHeaderLen		= 2;

 	static const int cdataHeaderLen		= 9;

+	static const int elementHeaderLen	= 1;

 

-	if ( XMLNode::StringEqual( p, commentHeader, commentHeaderLen ) ) {

+	if ( StringEqual( p, commentHeader, commentHeaderLen ) ) {

 		returnNode = new XMLComment( document );

 		p += commentHeaderLen;

 	}

+	else if ( StringEqual( p, elementHeader, elementHeaderLen ) ) {

+		returnNode = new XMLElement( document );

+		p += elementHeaderLen;

+	}

 	else {

 		TIXMLASSERT( 0 );

 	}

@@ -222,6 +228,7 @@
 	}

 }

 

+

 void XMLNode::PrintSpace( FILE* fp, int depth ) 

 {

 	for( int i=0; i<depth; ++i ) {

@@ -270,6 +277,12 @@
 }

 

 

+void XMLAttribute::Print( FILE* cfile )

+{

+	fprintf( cfile, "\"%s\"", value );

+}

+

+

 // --------- XMLElement ---------- //

 XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ),

 	name( 0 ),

@@ -385,6 +398,29 @@
 }

 

 

+void XMLElement::Print( FILE* cfile, int depth )

+{

+	PrintSpace( cfile, depth );

+	fprintf( cfile, "<%s", Name() );

+

+	for( XMLAttribute* attrib=rootAttribute; attrib; attrib=attrib->next ) {

+		fprintf( cfile, " " );

+		attrib->Print( cfile );

+	}

+

+	if ( firstChild ) {

+		fprintf( cfile, ">/n" );

+		for( XMLNode* node=firstChild; node; node=node->next ) {

+			node->Print( cfile, depth+1 );

+		}

+		fprintf( cfile, "</%s>", Name() );

+	}

+	else {

+		fprintf( cfile, "/>\n" );

+	}

+}

+

+

 // --------- XMLDocument ----------- //

 XMLDocument::XMLDocument() : 

 	charBuffer( 0 )

@@ -407,10 +443,12 @@
 	XMLNode* node = 0;

 	

 	char* q = Identify( this, charBuffer->mem, &node );

-	root->InsertEndChild( node );

-	node->ParseDeep( q );

-

-	return true;

+	if ( node ) {

+		root->InsertEndChild( node );

+		node->ParseDeep( q );

+		return true;

+	}

+	return false;

 }