Is there any easy known way to print the entire TiXmlDocument out to a string? I know how to do it through saving it to a file, but need the ability to pass it to a string without having to access files.
Thanx.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2004-09-16
ok, I tried adding the #define TIXML_USE_STL above the include of tinyxml.h, but I still get linking errors. Any ideas as to how to fix this, I've looked through the forum and tried some of the ideas that have fixed this for others but none seem to work. Not using MFC.
Thanx
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
are you sure you recompiled the library after #define TIXML_USE_STL? I've sometimes put it in there only to recompile my own program but not the library...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2004-09-16
that worked pretty well actually. Thanks for the quick responses. Hate to keep being a bother, this will work, but is there a way to save the formatting(tabs, new lines), or does tinyxml just dump all those when it dumps to the stream?
Thanx again!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there any easy known way to print the entire TiXmlDocument out to a string? I know how to do it through saving it to a file, but need the ability to pass it to a string without having to access files.
Thanx.
The easy way (requires STL mode on of course)
std::string str;
str << document0;
lee
ok, I tried adding the #define TIXML_USE_STL above the include of tinyxml.h, but I still get linking errors. Any ideas as to how to fix this, I've looked through the forum and tried some of the ideas that have fixed this for others but none seem to work. Not using MFC.
Thanx
There's a way to do this without STL :
TiXmlString get_xml_string (const TiXmlNode * node)
{
TiXmlString s;
TiXmlOutStream os_stream;
os_stream << * node;
s = os_stream;
return s;
}
This returns a TiXmlString, on which you can call the .c_str () method to have the C-string.
are you sure you recompiled the library after #define TIXML_USE_STL? I've sometimes put it in there only to recompile my own program but not the library...
that worked pretty well actually. Thanks for the quick responses. Hate to keep being a bother, this will work, but is there a way to save the formatting(tabs, new lines), or does tinyxml just dump all those when it dumps to the stream?
Thanx again!
Indents are just text nodes containing whitespace - if there are text nodes in your document tree they should write out as-is.
I have a vague memory of some whitespace eliminating switch though... can't remember for sure, but check that out.