XML file looks like:
<?xml version="1.0" standalone="no" ?> <ToDo> <!-- Do I need a secure PDA? --> </ToDo>
But after:
void main() { TiXmlDocument doc; TiXmlDocument doc2; TiXmlNode *root=0; TiXmlNode *node=&doc2;
doc.LoadFile("demotest.xml", TIXML_DEFAULT_ENCODING);
root=doc.RootElement(); node->Parse("<a>b</a>", 0, TIXML_DEFAULT_ENCODING); root->InsertEndChild(*node);
doc.SaveFile(); }
It looks like:
<?xml version="1.0" standalone="no" ?> <ToDo> <!-- Do I need a secure PDA? --> <a>b</a>
</ToDo>
unnecessary \r\n appeared
Interesting. Could you file this as a bug and include a zip of your code snippet / xml?
thanks very much, lee
I'm attach file on bug tracker
http://sourceforge.net/tracker/index.php?func=detail&aid=1307032&group_id=13559&atid=113559
Unfortunately v2.4.0 don't fix this bug :(
We'll pick it up in the next one. lee
I've solved this:
Cool, thanks!
I found something strange: "TextNode->InsertEndChild(&SomeNode)" should be NULL, but...
Example (demotest.xml): <?xml version="1.0" standalone="no" ?> <ToDo> <b>city</b> </ToDo>
Example (test.cpp): #include "tinyxml.h" #include <stdio.h>
void main() { TiXmlDocument doc; TiXmlElement element(""); TiXmlNode *node;
element.Parse("<ElName>My Text</ElName>", 0, TIXML_DEFAULT_ENCODING); node=doc.RootElement()->FirstChildElement()->FirstChild();
if (node=node->InsertEndChild(element)) printf("This message should not be shown:\n%s\n%s\n", node->Value(), node->Parent()->Value());
doc.SaveFile("demotest_2.xml"); }
I found the solution:
if (TextNode->ToElement()) TextNode->InsertEndChild(&SomeNode);
Log in to post a comment.
XML file looks like:
<?xml version="1.0" standalone="no" ?>
<ToDo>
<!-- Do I need a secure PDA? -->
</ToDo>
But after:
void main()
{
TiXmlDocument doc;
TiXmlDocument doc2;
TiXmlNode *root=0;
TiXmlNode *node=&doc2;
doc.LoadFile("demotest.xml", TIXML_DEFAULT_ENCODING);
root=doc.RootElement();
node->Parse("<a>b</a>", 0, TIXML_DEFAULT_ENCODING);
root->InsertEndChild(*node);
doc.SaveFile();
}
It looks like:
<?xml version="1.0" standalone="no" ?>
<ToDo>
<!-- Do I need a secure PDA? -->
<a>b</a>
</ToDo>
unnecessary \r\n appeared
Interesting. Could you file this as a bug and include a zip of your code snippet / xml?
thanks very much,
lee
I'm attach file on bug tracker
http://sourceforge.net/tracker/index.php?func=detail&aid=1307032&group_id=13559&atid=113559
Unfortunately v2.4.0 don't fix this bug :(
We'll pick it up in the next one.
lee
I've solved this:
http://sourceforge.net/tracker/index.php?func=detail&aid=1307032&group_id=13559&atid=113559
Cool, thanks!
I found something strange:
"TextNode->InsertEndChild(&SomeNode)" should be NULL, but...
Example (demotest.xml):
<?xml version="1.0" standalone="no" ?>
<ToDo>
<b>city</b>
</ToDo>
Example (test.cpp):
#include "tinyxml.h"
#include <stdio.h>
void main()
{
TiXmlDocument doc;
TiXmlElement element("");
TiXmlNode *node;
doc.LoadFile("demotest.xml", TIXML_DEFAULT_ENCODING);
element.Parse("<ElName>My Text</ElName>", 0, TIXML_DEFAULT_ENCODING);
node=doc.RootElement()->FirstChildElement()->FirstChild();
if (node=node->InsertEndChild(element))
printf("This message should not be shown:\n%s\n%s\n", node->Value(), node->Parent()->Value());
doc.SaveFile("demotest_2.xml");
}
I found the solution:
if (TextNode->ToElement())
TextNode->InsertEndChild(&SomeNode);