attribute support
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 07fa458..367f05c 100644
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -288,6 +288,9 @@
// --------- XMLAttribute ---------- //
char* XMLAttribute::ParseDeep( char* p )
{
+ p = ParseText( p, &name, "=" );
+ if ( !p || !*p ) return 0;
+
char endTag[2] = { *p, 0 };
++p;
p = ParseText( p, &value, endTag );
@@ -298,7 +301,8 @@
void XMLAttribute::Print( FILE* cfile )
{
- fprintf( cfile, "\"%s\"", value );
+ // fixme: sort out single vs. double quote
+ fprintf( cfile, "%s=\"%s\"", name.GetStr(), value.GetStr() );
}
@@ -351,7 +355,7 @@
}
// attribute.
- if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
+ if ( IsAlpha( *p ) ) {
XMLAttribute* attrib = new XMLAttribute( this );
p = attrib->ParseDeep( p );
if ( !p ) {
@@ -459,6 +463,7 @@
charBuffer = CharBuffer::Construct( p );
XMLNode* node = 0;
+ // fixme: clean up
char* q = Identify( this, charBuffer->mem, &node );
while ( node ) {
root->InsertEndChild( node );
diff --git a/tinyxml2.h b/tinyxml2.h
index 100ade0..ba5d031 100644
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -169,6 +169,7 @@
private:
char* ParseDeep( char* p );
+ StrPair name;
StrPair value;
XMLAttribute* next;
};
diff --git a/tinyxml2.suo b/tinyxml2.suo
index 62101d6..bcaeb41 100644
--- a/tinyxml2.suo
+++ b/tinyxml2.suo
Binary files differ
diff --git a/xmltest.cpp b/xmltest.cpp
index 322d25c..4972275 100644
--- a/xmltest.cpp
+++ b/xmltest.cpp
@@ -28,13 +28,15 @@
}
#endif
{
- static const char* test[] = { "<!--single element-->",
+ static const char* test[] = { //"<!--single element-->",
"<element />",
"<element></element>",
- "<!--single sub-element-->",
+ //"<!--single sub-element-->",
"<element><subelement/></element>",
"<element><subelement></subelement></element>",
"<!--comment beside elements--><element><subelement></subelement></element>",
+ "<!--comment beside elements, this time with spaces--> \n <element> <subelement> \n </subelement> </element>",
+ "<element attrib1='foo' attrib2=\"bar\" ></element>",
0
};
for( int i=0; test[i]; ++i ) {