Menu

STL TiXmlText->Value() broken?

systemdown
2005-07-02
2013-05-20
  • systemdown

    systemdown - 2005-07-02

    Hi,

    I cannot retrieve the value of a TiXmlText node (i.e. the CDATA child of an element) when using the STL build.

    When using the non-STL build, it works just fine.

    The following code linked with the STL-enabled library yields "Empty string!" whilst linking with non-STL library prints the expected text ("Got string: 1.1 Start easy ignore fin thickness").

    Code follows:

    TiXmlDocument doc("test6.xml");
    doc.LoadFile();

    TiXmlHandle docHandle(&doc);

    TiXmlText* txt = docHandle.ChildElement("element",0).ChildElement("Name",0).FirstChild().Text();

    std::string str(txt->Value());
    if (str == "") {
        std::cerr << "Empty string!" << std::endl;
    } else {
        std::cout << "Got string: " << str << std::endl;
    }

    Note that txt->Value() with STL-enabled library returns non-NULL, it returns an empty string.

    Any ideas?

    All demo tests passed 100% with the STL build, but I cannot get the value of a text node no matter how I go about it.  I've tried multiple combinations of handlers, child iterators, casts etc. and can never get the text node's value (besides the empty string, of course).

    I'm using the latest MinGW 4.1.0 (gcc version 3.4.2 mingw-special) with MSYS-1.0.10.

    Cheers.

     
    • Ellers

      Ellers - 2005-07-03

      Can you post the XML that shows the problem?

      When you say "the CDATA child of an element" to do you mean a CDATA node or the concept of char data? i.e. do you mean "Hello" in

        <Node>Hello</Hello>

      or

        <node><![CDATA[hello]]></node>

      ?
      Ellers

       
    • systemdown

      systemdown - 2005-07-03

      Thanks for the reply.

      The XML is 'test6.xml' from the TinyXML distribution, it is as follows:

      <element><Name>1.1 Start easy ignore fin thickness&#xA;</Name></element>

      And yes, my meaning of CDATA was just the concept of arbitrary character data which appears between an opening XML tag and closing XML tag, such as the string "Hello" from your example "<Node>Hello</Node>".  Apologies for making this unclear.

      It does not matter what the string is; I simply cannot retrieve the string's value in ANY case whatsoever, when linking against the STL build of the TinyXML library, so from your example I cannot get "Hello" at all using Value() on the node.

      However as previously stated, when I use the non-STL build of the library it works just fine - the exact same XML will return the expected string values using the exact same code.

      I'm sure the problem isn't with my compiler's STL; I'm using a brand new installation of MinGW 4.1.

      Cheers

       
    • Lee Thomason

      Lee Thomason - 2005-07-24

      I entered a bug, although I haven't verified it yet.

      lee

       

Log in to post a comment.