Menu

Possible bug in TiXmlElement::ReadValue

Developer
2007-04-30
2013-05-20
  • glewandowski

    glewandowski - 2007-04-30

    I am storing a delimiter for a csv file, usually a comma, but they occasionally want a tab to separate values.  The tab is being stored in the file (by TinyXml) thusly:

            <Delimiter>&#x09;</Delimiter>

    (if this gets translated in posting, the characters between > and < are ampersand, pound, ecks, zero, nine.)

    My knowledge of XML is not sufficient for me to know that this is correct.  When this value is read in, it is correctly assigned to a string, length 1, value 0x09.  However at this point in the function:

    if ( !textNode->Blank() )
        LinkEndChild( textNode );
    else
        delete textNode;

    the Blank() call returns true, and the text node is not appended.  Again, I don't know if this is correct behavior, but it looks fishy to me.

    I'm going to encode this delimiter differently, ("comma"/"tab"), but I thought I would report it.

     
    • Ellers

      Ellers - 2007-04-30

      Hmm.

      On its own, this does not look like a bug to me.

      A bit tricky, to be sure, but not a bug.

      On one hand, I've mentioned here before that text nodes should be left exactly as they are when reading or writing XML -- or have a switch to operate like that, because some people care about whitespace (like you) or others who don't.

      I'd say that you're better off encoding the delimiter as a word anyway, as you have. Its clearer and more visible. If you could save the xml with a real tab char, then load the file, it wouldn't be immediately clear to the viewer what that character was - or it would look like there was nothing there. This way it is 100% clear.

      HTH

       

Log in to post a comment.