The dump_to_stdout example from the TinyXML tutorial does not work with TinyXML++.

326 views
Skip to first unread message

KimJarvis

unread,
Jul 2, 2009, 3:31:30 PM7/2/09
to TinyXML++
The dump_to_stdout example from the TinyXML tutorial does not work
with TinyXML++.

Using tinyxml_2_4_2 with TinyXML++ from the read only repository. The
checks in xmltest.cpp completed successfully. However:

The tutorial example with headers:

#define TIXML_USE_TICPP
#include "tinyxml/ticpp.h"

Produces:

example.xml:
Document
+ Declaration
+ Element [Hello]

The tutorial example with headers:

//#define TIXML_USE_STL
//#include "tinyxml/tinyxml.h"

example.xml:
Document
+ Declaration
+ Element [Hello]
(No attributes)
+ Text: [World]

The error occurs in tinystr.h
// Convert a TiXmlString into a null-terminated char *
const char * c_str () const { return rep_->str; }

The line of the example being executed is:
printf( "%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value
());

Ryan Pusztai

unread,
Jul 2, 2009, 8:41:10 PM7/2/09
to ti...@googlegroups.com
I think that is part of TinyXML and not of TinyXML++ so I think you should post this bug on there mailing list. Unless I misunderstand you. We wrap TinyXML so if there is a tutorial that is specific to just TinyXML then we don't touch it.

The TinyXML++ example should work flawlessly. Let me know if you have othre thoughts.
--
Regards,
Ryan

KimJarvis

unread,
Jul 6, 2009, 12:24:46 PM7/6/09
to TinyXML++
This problem is specific to TinyXML++. The problem is that the
TinyXML copy-and-paste demo program from the tutorial fails during
execution when TIXML_USE_TICPP is defined.

http://www.grinninglizard.com/tinyxmldocs/tutorial0.html

It is my understanding that TinyXML++ is a wrapper and that programs
using tinyXML, but not the TinyXML++ features, should execute whether
TIXML_USE_TICPP is defined or not. Maybe my understanding of what is
meant by wrapper function in this case is incorrect?

I tried using both the GCC and intel compilers and got the same
problem. As noted above the installation is correct and the
xmltest.cpp program completes without errors.

In the tutorial example routine:

int dump_attribs_to_stdout(TiXmlElement* pElement, unsigned int
indent)
{
if ( !pElement ) return 0;
TiXmlAttribute* pAttrib=pElement->FirstAttribute();

Returns a bad value for the pointer to the attributes.

The cause of this problem is in tinyxml.h
TiXmlAttribute* First() { return ( sentinel.next ==
&sentinel ) ? 0 : sentinel.next; }
Where sentinel.next is junk, causing the program to behave as if there
is an attribute when there is not. The subsequent attempt to print
the attribute fails as described in my first post.

When the definition of TIXML_USE_TICPP is removed the program
correctly determines that there are no attributes.







Ryan Pusztai

unread,
Jul 6, 2009, 5:08:04 PM7/6/09
to ti...@googlegroups.com
OK. now I understand, can you please make this an issue in the GoogleCode issue tracker so we can track this properly.
--
Regards,
Ryan

KimJarvis

unread,
Jul 7, 2009, 7:30:18 AM7/7/09
to TinyXML++
Created ticpp issue 52 to track this problem.
Reply all
Reply to author
Forward
0 new messages