Menu

How to get TiXmlText value

Anonymous
2004-06-16
2004-06-16
  • Anonymous

    Anonymous - 2004-06-16

    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!!
       

     
    • Ellers

      Ellers - 2004-06-16

      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"

       
    • Anonymous

      Anonymous - 2004-06-16

      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?

       
    • Yves Berquin

      Yves Berquin - 2004-06-16

      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.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.