This one of the several ways I have tried it but it keeps giving me the "item" tag name in that last printf. (I have tried these methods according to the xmltest.cpp file)
Thanks in advance :)
Diilbert
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There's part of me that thinks "yes, obviously a text node is contained in the element node".
But the other part of me (the, er, nicer part ;) can remember when all of this stuff was unclear and confusing.
The good news is that this approach is common in the general DOM approach to XML processing, so if/when you work with other toolkits, you won't be as surprised :)
Perhaps if multiple people are having these sorts of problems the intro TinyXml doc could start off with some simple examples?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is an example on the main page of the docs, which shows how a sample XML file breaks down into nodes, including several TiXmlText elements. I know it's perhaps not very intuitive but it is definitely documented.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
True. And its all there in the sample/test program too, although it takes a bit of reading to get to. Just sometimes for beginners it might be good to hand-hold through some basic steps up front and early in the docs :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I really like your parser and I want to use it in a project I am working on, but I am still cannot figure out how to get the text between two tags.
Here is the xml I am using...
<test>
<item>TEST</item>
</test>
Here my code (very simple)
TiXmlDocument doc;
Load file to doc;
Check for errors ;
TiXmlNode* node = 0;
TiXmlElement* itemElement = 0;
node = doc.RootElement();
node = node->FirstChild();
itemElement = node->ToElement();
assert(itemElement);
printf("Type: %i\r\n",itemElement->Type());
printf("Item Element: %s\r\n",itemElement->Value());
This one of the several ways I have tried it but it keeps giving me the "item" tag name in that last printf. (I have tried these methods according to the xmltest.cpp file)
Thanks in advance :)
Diilbert
I think it was the same problem I had and posted about this week. It turns out that you need to go down one more using FirstChild().
See <https://sourceforge.net/forum/forum.php?thread_id=1225127&forum_id=42748>.
There's part of me that thinks "yes, obviously a text node is contained in the element node".
But the other part of me (the, er, nicer part ;) can remember when all of this stuff was unclear and confusing.
The good news is that this approach is common in the general DOM approach to XML processing, so if/when you work with other toolkits, you won't be as surprised :)
Perhaps if multiple people are having these sorts of problems the intro TinyXml doc could start off with some simple examples?
There is an example on the main page of the docs, which shows how a sample XML file breaks down into nodes, including several TiXmlText elements. I know it's perhaps not very intuitive but it is definitely documented.
True. And its all there in the sample/test program too, although it takes a bit of reading to get to. Just sometimes for beginners it might be good to hand-hold through some basic steps up front and early in the docs :)
Andrew: Thanks...
According to what I read on the main doc page of the web page my code should have worked.....
Oh well... thanks anyway :p
By the way thanks for the awesome class :)