我正在尝试使用 Tinyxml 递归读取 Xml 文件,但是当我尝试访问数据时,我得到一个“分段错误”。这是代码:
int id=0, categoria=0;
const char* nombre;
do{
ingrediente = ingrediente->NextSiblingElement("Ingrediente");
contador++;
if(ingrediente->Attribute("id")!=NULL)
id = atoi( ingrediente->Attribute("id") );
if(ingrediente->Attribute("categoria")!=NULL)
categoria = atoi ( ingrediente->Attribute("categoria") );
if(ingrediente!=NULL)
nombre = ( ( ingrediente->FirstChild() )->ToText() )->Value();
}while(ingrediente);
出于某种原因,三个“if”行向我抛出了分段错误,但我不知道问题出在哪里。
提前致谢。