Menu

Character Entities

2008-03-31
2013-05-20
  • JC Francois

    JC Francois - 2008-03-31

    Hi,

    I can't seem to get entities handled properly. The documentation (http://www.grinninglizard.com/tinyxmldocs/index.html) says:
    TinyXML recognizes the pre-defined "character entities". These are recognized when the XML document is read, and translated to there UTF-8 equivalents. For instance, text with the XML of "Far & Away" will have the Value() of "Far & Away" when queried from the TiXmlText object.

    Here's my test case:

    File test.xml:

    <?xml version="1.0" encoding="utf-8" ?>
    <unicode_test>Here's an ampersand: &amp; and here's another one: &#x26;</unicode_test>

    My code:
    TiXmlDocument Doc("test.xml");
    bool loadOkay = Doc.LoadFile();
    if (loadOkay)
    {
        TiXmlHandle DocH(&Doc);
        const char* TextValue = DocH.FirstChild("unicode_test").FirstChild().ToText()->Value();
    }

    When I watch the value of TextValue I get "Here's an ampersand: &amp; and here's another one: &#x26;" instead of the expected UTF-8 equivalent string.

    What am I doing wrong? How can I get TinyXML to handle character entities as UTF-8?

    Thanks,

    ~/jc

     
    • JC Francois

      JC Francois - 2008-04-07

      Can somebody point me in the right direction please?

      Thanks,

      /~jc

       
    • JC Francois

      JC Francois - 2008-07-25

      Can somebody please help?

      Thanks,

      /~jc

       

Log in to post a comment.