First, sorry for my english. I'm spanish and i have small problems with the language.
I have one problem with TinyXml. I have the next xml document (from the main page of the project):
<?xml version="1.0" standalone=no>
<!-- Our to do list data -->
<ToDo>
<Item priority="1"> Go to the <bold>Toy store!</bold></Item>
<Item priority="2"> Do bills</Item>
</ToDo>
I want to acces to the first item, Item priority="1". I try:
TiXmlHandle docHandle(&doc);
TiXmlElement* child = docHandle.FirstChild("ToDo").FirstChild("Item").Element();
if (child){
// do something useful
}
Well, this is correct. But if i try to access to a no-existing member, for example, Item2:
TiXmlElement* child = docHandle.FirstChild("ToDo").FirstChild("Item2").Element();
if (child){
// the program crashes
}
the program crashes and break. What can i do for check if an element exist? I need parse a documents with elements of which I don't know the name. If i could acces with de "docHandle", the program is very easy of programming. Any idea? Thank you.
Sorry for my english...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First, sorry for my english. I'm spanish and i have small problems with the language.
I have one problem with TinyXml. I have the next xml document (from the main page of the project):
<?xml version="1.0" standalone=no>
<!-- Our to do list data -->
<ToDo>
<Item priority="1"> Go to the <bold>Toy store!</bold></Item>
<Item priority="2"> Do bills</Item>
</ToDo>
I want to acces to the first item, Item priority="1". I try:
TiXmlHandle docHandle(&doc);
TiXmlElement* child = docHandle.FirstChild("ToDo").FirstChild("Item").Element();
if (child){
// do something useful
}
Well, this is correct. But if i try to access to a no-existing member, for example, Item2:
TiXmlElement* child = docHandle.FirstChild("ToDo").FirstChild("Item2").Element();
if (child){
// the program crashes
}
the program crashes and break. What can i do for check if an element exist? I need parse a documents with elements of which I don't know the name. If i could acces with de "docHandle", the program is very easy of programming. Any idea? Thank you.
Sorry for my english...
Hi there,
I don't see the problem from your code..
Can you post a small but complete program that shows the problem?
Ellers