!DOCTYPE declarations

Drew Leske
2002-09-02
2013-05-20
  • Drew Leske

    Drew Leske - 2002-09-02

    Hi all,

    First: great work on a great little library! :)

    I have one question regarding DTD's.  I know TinyXML does not "parse or use" DTD's, but I was hoping it would safely ignore them.  The reason for this is that I would like to be able to have the document validated by one of myriad tools available to do so before the document is published (after which it will be used by a client making use of TinyXML).  My document therefore has an internal DTD ("<!DOCTYPE blah [ ... ]>") but this causes problems for TinyXML.  Perhaps I'm doing something wrong in my parsing?

    Again, thanks for a great little library and for spreading support of an excellent standard!

    dlek.

     
    • Matt Rudder

      Matt Rudder - 2004-05-07

      I've been trying to come up with a method to do the same thing. You could just iterate through the sibling nodes, until you reach the node you want to start from. The only problem, is the parser tends to blow up on the end of the DOCTYPE tag. (ie, the ]> part of the tag.)

      Here's the code I have so far... Maybe someone can help us find a way to deal with the end of the tag.

      TiXmlDocument doc( "data.xml" );
      TiXmlNode* root = doc.FirstChild();
      while(root->Value() != "tagtofind")
      {
          root = root->NextSibling();
      }

       
    • Lee Thomason

      Lee Thomason - 2004-05-10

      I'm working on the next version, maining UTF-8, but also trying to clean up some problems like this. I added a bug:

      http://sourceforge.net/tracker/index.php?func=detail&aid=950171&group_id=13559&atid=113559

      Could you add a small test case that illustrates the problem and post it to the bug? It's a simple test, but experience shows that if I make test cases, I sometimes miss a use case that people want.

      thanks,
      lee

       
    • Alexey Sokirko

      Alexey Sokirko - 2004-10-15

      I think, I had the same problem with TinyXml, and I hope, I have solved it somehow. You have to change a little bit  the function, which is called TiXmlUnknown::Parse (counting nestedness of "<",">"). So the main while cycle now should
      look like as follows:

      size_t nestedness = 1;   
      while (p  && *p &&    ( *p != '>'  || (nestedness > 1)  ))
      {
      value += *p;
      if (*p == '<')
         nestedness++;
      else
         if (*p == '>')
           nestedness--;

        ++p;
      }

       
  • Lance Drake

    Lance Drake - 2011-08-10

    Another thing which I would like to see from TinyXML is the specific mention of the legal inclusion of the well-formed XML header:

    <?xml version="1.0" encoding="UTF-8"?>
    

    So far, it does not appear to present a problem - but with all the caveats about what can NOT be included in a TinyXML document, it would be comforting to know that including the XML specifier as shown above would never present a problem.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks