How can I get text values from a xml document and give the values to CString parameters in mfc Program.
ex) person.xml <Person> <First>Vernon</First> <Person>
I tried to use TiXmlHandle to get text values like below
CString m_strFirst;
TiXmlDocument doc("person.xml"); doc.LoadFile(); TiXmlHandle docH(&doc); TiXmlText* text =docH.FirstChild("Person"). FirstChildElement("First").Child(0).Text();
m_strDate= text->Value(); // it doesn't work
How do I get text value for CString variables.
I will thank you for your help!!
This is probably not helpful, but just in case ...
in your code example you declare m_strFirst and then you assign the text value to a different variable "m_strDate"
Thanks for knowing my mistake. ya, the variable should be corrected from "m_strDate" to "m_strDate".
But when I run the code I still get an error with value() function. I guess that is conversion problem.
how can I fix this?
Your XML is wrong ! Should be : <Person> <First>Vernon</First> </Person>
You have a missing "/" in the closing of the main element
Log in to post a comment.
How can I get text values from a xml document and give the values to CString parameters in mfc Program.
ex) person.xml
<Person>
<First>Vernon</First>
<Person>
I tried to use TiXmlHandle to get text values like below
CString m_strFirst;
TiXmlDocument doc("person.xml");
doc.LoadFile();
TiXmlHandle docH(&doc);
TiXmlText* text =docH.FirstChild("Person").
FirstChildElement("First").Child(0).Text();
m_strDate= text->Value(); // it doesn't work
How do I get text value for CString variables.
I will thank you for your help!!
This is probably not helpful, but just in case ...
in your code example you declare m_strFirst and then you assign the text value to a different variable "m_strDate"
Thanks for knowing my mistake.
ya, the variable should be corrected from
"m_strDate" to "m_strDate".
But when I run the code I still get an error with value() function. I guess that is conversion problem.
how can I fix this?
Your XML is wrong !
Should be :
<Person>
<First>Vernon</First>
</Person>
You have a missing "/" in the closing of the main element