Your code is correct, and gives the right results here.
Something must be wrong with your setup.
You open the file on the local directory : are you sure you read the right file ?
Yves
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi !
I am trying to get a text in a element. I use dev-cpp 4.9.9.2 and tinyxml 2.3.4.
test.xml:
<?xml version="1.0" encoding="UTF-8"?>
<SCTemplate>name</SCTemplate>
test.cpp:
TiXmlDocument doc;
doc.LoadFile("test.xml");
TiXmlNode *node= doc.RootElement();
if(node->ToElement())
printf("value:%s\n",node->Value());
node = node->FirstChild();
if(node->ToText())
printf("value:%s\n",node->Value());
stdout:
value:SCTemplate
value:
I am becoming crazy! help me plz ^^
thx
Your code is correct, and gives the right results here.
Something must be wrong with your setup.
You open the file on the local directory : are you sure you read the right file ?
Yves
i added doc.Print(stdout);
stdout:
<?xml version="1.0" encoding="UTF-8"?>
<SCTemplate>name</SCTemplate>
value:SCTemplate
value:
i don't want go back to libxml or xerces /cry
PS: xmltest.cpp works ==> pass 104, fail 0
...that is wacky. Can you look at it in a debugger and tell what it child node is?
lee
I have reinstalled dev-cpp + tinyxml, created a new workspace with same files (test.xml and test.cpp):
now i can get my text value!
i probably had a wrong setup or old tinyxml.dll in same folder....sorry
thx for your help