CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: TinyXml

  1. #1
    Join Date
    Dec 2011
    Posts
    21

    TinyXml

    Hi
    I want to read data from such a file: http://www.rytec.be/tools/rytec.channels.xml.gz
    I decided to try tinyxml, as it seemed easy.
    But the reading the file is overwhelming to me.
    I don't understand what's the handle thing is and because of this nothing further.
    Could somebody explain me how to read such a file?
    Thanks in advance
    marmistrz

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: TinyXml

    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Dec 2011
    Posts
    21

    Re: TinyXml

    Yeah...
    Another day I tried again and finally I think I understood it. I found a reasonable example which let me understand it here: http://stackoverflow.com/questions/7...ecific-element
    But still I don't know how to start parsing from a comment.

    In the file there's a comment, e.g.

    Code:
    <!-- Poland -->
    And I'd like to start parsing from this to another comment (it'd be defined which comment)

  4. #4
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    Re: TinyXml

    tinyxml doesn't work that way.

    It is a DOM parser, meaning it will parse the ENTIRE xml, and load the DOM into memory. From there, you just access/manipulate the data as you feel, but there is no more parsing to be done.

    tinyxml meant to be very light, and very easy to use, and purposefully does not provide certain functionality, such as SAX parsing.

    Is your XML huge? Can it not fit into memory?

    ----
    As for your question about handler, IMO, it is not that important to understand how it works, or even use. It is a convenience tool. Use if you feel comfortable with it.
    Is your question related to IO?
    Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
    It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.

  5. #5
    Join Date
    Dec 2011
    Posts
    21

    Re: TinyXml

    I must've used a wrong verb

    I just want to read the xml from the part the comment is...

    i've got

    Code:
    ... // some data
    <!-- Poland -->
    ... // more data
    <!-- another comment -->
    And I'd like to access ony the information between <!-- Poland --> and <!-- another comment -->

  6. #6
    Join Date
    Aug 2008
    Posts
    902

    Re: TinyXml

    Well, comments are parsed into the DOM as TiXmlComment, so you should be able to locate the comments. That being said, I think what you are doing is wrong. I don't think you should be using comments to structure or contain data, that's not what they are meant for. Whatever it is you are trying to do, I am positive you can do it without comments.

  7. #7
    Join Date
    Dec 2011
    Posts
    21

    Re: TinyXml

    I've got an idea: use fstream (or better library for this if you know some)
    And copy to another file "the headers" (whats common for all data) and the specific data I want (the one I mentioned)
    This'd have one bif advantage: it'd save RAM - and it's a handheld device

    Ps. Is it possible for tinyxml to parse first only some (for instance 100 lines), then remove the read data from ram and load next elements??

  8. #8
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: TinyXml

    No it's not possible since as monarch_dodra said it's a DOM parser. Maybe you should use a SAX parser like for instance expat instead?
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  9. #9
    Join Date
    Dec 2011
    Posts
    21

    Re: TinyXml

    Thanks for your answers!

  10. #10
    Join Date
    Dec 2011
    Posts
    3

    Re: TinyXml

    And I'd like to start parsing from this to another comment (it'd be defined which comment)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured