hello,world working. Forgot how hard XML parsing can be.
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 63b8707..cfe2969 100644
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -74,6 +74,13 @@
void XMLNode::Print( FILE* fp, int depth )
{
+ for( XMLNode* node = firstChild; node; node=node->next ) {
+ node->Print( fp, depth );
+ }
+}
+
+void XMLNode::PrintSpace( FILE* fp, int depth )
+{
for( int i=0; i<depth; ++i ) {
fprintf( fp, " " );
}
@@ -138,6 +145,7 @@
XMLDocument::XMLDocument() :
charBuffer( 0 )
{
+ root = new XMLNode( this );
}
@@ -153,8 +161,11 @@
{
charBuffer = CharBuffer::Construct( p );
XMLNode* node = 0;
+
char* q = Identify( charBuffer->mem, &node );
+ root->InsertEndChild( node );
node->ParseDeep( q );
+
return true;
}
@@ -184,13 +195,19 @@
// - Everthing else is unknown to tinyxml.
//
- const char* xmlHeader = { "<?xml" };
- const char* commentHeader = { "<!--" };
- const char* dtdHeader = { "<!" };
- const char* cdataHeader = { "<![CDATA[" };
+ static const char* xmlHeader = { "<?xml" };
+ static const char* commentHeader = { "<!--" };
+ static const char* dtdHeader = { "<!" };
+ static const char* cdataHeader = { "<![CDATA[" };
- if ( XMLNode::StringEqual( p, xmlHeader, 5 ) ) {
+ static const int xmlHeaderLen = 5;
+ static const int commentHeaderLen = 4;
+ static const int dtdHeaderLen = 2;
+ static const int cdataHeaderLen = 9;
+
+ if ( XMLNode::StringEqual( p, commentHeader, commentHeaderLen ) ) {
returnNode = new XMLComment( this );
+ p += commentHeaderLen;
}
else {
TIXMLASSERT( 0 );
diff --git a/tinyxml2.h b/tinyxml2.h
index 22d9d3e..2ff58c9 100644
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -48,7 +48,7 @@
public:
XMLNode* InsertEndChild( XMLNode* addThis );
- void Print( FILE* cfile, int depth ); // prints leading spaces.
+ virtual void Print( FILE* cfile, int depth );
protected:
XMLNode( XMLDocument* );
@@ -90,6 +90,7 @@
XMLNode* next;
private:
+ void PrintSpace( FILE* cfile, int depth ); // prints leading spaces.
};
@@ -100,7 +101,7 @@
XMLComment( XMLDocument* doc );
virtual ~XMLComment();
- void Print( FILE* cfile, int depth );
+ virtual void Print( FILE* cfile, int depth );
protected:
char* ParseDeep( char* );
diff --git a/tinyxml2.suo b/tinyxml2.suo
index e447d8f..4fe777e 100644
--- a/tinyxml2.suo
+++ b/tinyxml2.suo
Binary files differ