|
-
December 7th, 2011, 01:05 PM
#1
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
-
December 7th, 2011, 01:26 PM
#2
-
December 9th, 2011, 10:10 AM
#3
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.
And I'd like to start parsing from this to another comment (it'd be defined which comment)
-
December 9th, 2011, 11:35 AM
#4
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.
-
December 9th, 2011, 02:01 PM
#5
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 -->
-
December 9th, 2011, 07:54 PM
#6
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.
-
December 10th, 2011, 02:44 AM
#7
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??
-
December 10th, 2011, 07:19 AM
#8
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?
-
December 10th, 2011, 11:26 AM
#9
-
December 15th, 2011, 01:46 AM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|