Everything works fine as long as I use tinyxml by adding the cpp files to my project.
When using a static lib the function returns the second! vendor-node, and there also acccess violations with other functions.
I've tried various TLib and compiler options when building the library with no success.
(Borland BCB4)
Any ideas? Thank you
W.Johann
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
All I would say is that this is a prime example of when to use a debugger. With a small data file like this it should be practical to single-step through the code and see what's going wrong. You could even try printing out some details of each TiXmlNode as you loop through them to see what is being processed.
You're also mixing a lot of pointers and references in there. It's possible you're trashing one of the pointed-to objects somewhere along the line. You don't change nodename, attrname, or attrvalue, so they may as well be passed by value anyway, or at least by const reference.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At first many thanks for the great tinyxml !
I've encountered a problem when using tinyxml in a static lib.
example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<theroot>
<!--Copyright: -->
<Vendor name="vendor1">
<System name="A">
</System>
</Vendor>
<Vendor name="vendor2">
<System name="B">
</System>
</Vendor>
</theroot >
I use this for searching the first vendor:
TiXmlNode* next = 0;
TiXmlElement* elem = 0 ;
for( next= root->FirstChild(); next; next=next->NextSibling(nodename) )
{
if(elem = next->ToElement()) {
cout << endl << "attr: " << elem->Attribute("name");
if( elem->Attribute(name)==attrval )
break;
}
}
At first many thanks for the great tinyxml !
I've encountered a problem when using tinyxml in a static lib.
example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<theroot>
<!--Copyright: -->
<Vendor name="vendor1">
<System name="A">
</System>
</Vendor>
<Vendor name="vendor2">
<System name="B">
</System>
</Vendor>
</theroot >
I use this for searching the first vendor:
nodename=vendor;
attrname=name;
attrval=vendor1;
TiXmlElement* SearchNode(TiXmlNode* root, string& nodename, string& attrname, string& attrval)
{
TiXmlNode* next = 0;
TiXmlElement* elem = 0 ;
for( next= root->FirstChild(); next; next=next->NextSibling(nodename) )
{
if(elem = next->ToElement()) {
if( elem->Attribute(attrname)==attrval )
break;
}
}
return elem;
}
Everything works fine as long as I use tinyxml by adding the cpp files to my project.
When using a static lib the function returns the second! vendor-node, and there also acccess violations with other functions.
I've tried various TLib and compiler options when building the library with no success.
(Borland BCB4)
Any ideas? Thank you
W.Johann
All I would say is that this is a prime example of when to use a debugger. With a small data file like this it should be practical to single-step through the code and see what's going wrong. You could even try printing out some details of each TiXmlNode as you loop through them to see what is being processed.
You're also mixing a lot of pointers and references in there. It's possible you're trashing one of the pointed-to objects somewhere along the line. You don't change nodename, attrname, or attrvalue, so they may as well be passed by value anyway, or at least by const reference.