Menu

Another Whitespace question

Developer
2005-11-21
2013-05-20
  • glewandowski

    glewandowski - 2005-11-21

    I am saving a character to be the delimiter for csv files (comma or tab).  TinyXML is writing the tab character like this:

    <Delimiter>&#x09;</Delimiter>

    but when it is read back in, the text is thrown away in this section of TiXmlElement::ReadValue at line 1155 in tinyxmlparser (from version 2.4.2, unpatched):

    if ( TiXmlBase::IsWhiteSpaceCondensed() )
    {
        p = textNode->Parse( p, data, encoding );
    }
    else
    {
        // Special case: we want to keep the white space
        // so that leading spaces aren't removed.
    p = textNode->Parse( pWithWhiteSpace, data, encoding );
                }

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

     
    • glewandowski

      glewandowski - 2005-11-21

      repost with the part truncated accidentally:

      I am saving a character to be the delimiter for csv files (comma or tab). TinyXML is writing the tab character like this:

      <Delimiter>&#x09;</Delimiter>

      but when it is read back in, the text is thrown away in this section of TiXmlElement::ReadValue at line 1155 in tinyxmlparser (from version 2.4.2, unpatched)(yes, IsWhiteSpaceCondensed is false):

      if ( TiXmlBase::IsWhiteSpaceCondensed() )
      {
          p = textNode->Parse( p, data, encoding );
      }
      else
      {
      // Special case: we want to keep the white space
      // so that leading spaces aren't removed.
          p = textNode->Parse( pWithWhiteSpace, data,     encoding );
      }

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

      The entity is properly parsed into a std::string of length one, contents 0x10, as it should be.  However 'textNode->Blank()' tests true and the node is thrown away.  I'm guessing this is a bug, and not correct XML, but I'm not sure.

       
    • Lee Thomason

      Lee Thomason - 2005-11-22

      TinyXML in its default mode throws away white space. (Getting white space parsing consistent with the XML spec is fairly high on my todo, but for now it works more like HTML.) You may be able to work around your problem by setting CondenseWhiteSpace to 'false'.

      lee

       

Log in to post a comment.

MongoDB Logo MongoDB