Menu

Very nice; just 2 small problems

Anonymous
2002-04-15
2002-04-16
  • Anonymous

    Anonymous - 2002-04-15

    Hello

    Very nice product indeed.  Congratulations for it and, especially, many thanks.  After looking at expat and xerxes, this is really the yhing I was looking for.
    I'm writing a configuration registry system on top of TinyXML.  I works great; I just encountered two problems small:
    - When adding elements without child elements; only the end tag of that element makes it into the saved file.
    - When using the function to insert a child node before another one and that other one is the first child node, an Access Violation occurs
    - The same goes for inserting a child node after the last one.

    The last two problems were fixed when I changed the next two functions as written here:

    TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis )
    {
       if(beforeThis->parent != this)
          return 0;

       TiXmlNode* node = addThis.Clone();
       if(!node)
          return 0;
       node->parent = this;

       node->next = beforeThis;
       node->prev = beforeThis->prev;
       if(beforeThis->prev)
       {
          beforeThis->prev->next = node;
       }
       else
       {
          this->firstChild = node;
       };
       beforeThis->prev = node;
       return node;
    }

    TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis )
    {
       if(afterThis->parent != this)
          return 0;

       TiXmlNode* node = addThis.Clone();
       if(!node)
          return 0;
       node->parent = this;

       node->prev = afterThis;
       node->next = afterThis->next;
       if(afterThis->next)
       {
          afterThis->next->prev = node;
       }
       else
       {
          this->lastChild = node;
       };
       afterThis->next = node;
       return node;
    }

    Best regards

    Frank De prins
    Antwerp - Belgium

     
    • Yves Berquin

      Yves Berquin - 2002-04-15

      Frank,

      I have a question for your first problem :
      Are you sure it's only the end tag ?
      I believe it's the "empty tag" form :

      <parent>
         <emptychild />
      </parent>

      This is a valid construction in XML, which is an exact match of :

      <parent>
         <emptychild></emptychild>
      </parent>

      TinyXML always generates the first form when an empty element with no children is found.

      Take care
      Yves

       
      • Anonymous

        Anonymous - 2002-04-15

        Hello Yves

        It is indeed the empty form; sorry. 
        Thanks for the explanation; I did not know that.  I know very little about XML; the only thing I intend to do with it is use it to store my applications configuration information.  That is why I was so happy to find such a light-weight, yet full-featured library as TinyXML.

        Best regards

        Frank

         
    • Lee Thomason

      Lee Thomason - 2002-04-16

      Thanks! Glad it was useful. I'll wrap the bug fixes into the trunk (thanks!) and incorporate it 2.0.1. I'm looking at getting that out in the next week or 2 -- I've been sitting on the Beta, trying to get as much feedback as possible.

       

Log in to post a comment.