string name;
//LOADING XML FILE
TiXmlDocument doc(file);
doc.LoadFile();
//IF NOT LOADED, PRINT ERROR
if(!doc.LoadFile())
{
cout<< "Error while loading file:\n", doc.ErrorDesc();
}
//FIND THE ROOT
TiXmlElement *root = doc.RootElement();
dataset=root->Attribute("name");
//FOR-LOOP FOR GOING THROUGH THE XML ELEMENTS AND TAKING OUT ITS ATTRIBUTES
for( TiXmlElement* elementElement = root->FirstChildElement("element"); elementElement; elementElement = elementElement->NextSiblingElement("element") )
{
//catch from every element the name
name = elementElement->Attribute("name");
}
Hi,
How do i get the name of a TiXmlNode ?
i.e. <test attr="bla" />
how do i get the name of this tag ? I can search for tagnames, but i dont know how to get the name, if im iterating the nodes.
oh ive found the function. sorry.
Could you tell me the function? I don't found it :(
string name;
//LOADING XML FILE
TiXmlDocument doc(file);
doc.LoadFile();
//IF NOT LOADED, PRINT ERROR
if(!doc.LoadFile())
{
cout<< "Error while loading file:\n", doc.ErrorDesc();
}
//FIND THE ROOT
TiXmlElement *root = doc.RootElement();
dataset=root->Attribute("name");
//FOR-LOOP FOR GOING THROUGH THE XML ELEMENTS AND TAKING OUT ITS ATTRIBUTES
for( TiXmlElement* elementElement = root->FirstChildElement("element"); elementElement; elementElement = elementElement->NextSiblingElement("element") )
{
//catch from every element the name
name = elementElement->Attribute("name");
}
or what do you mean???
my xml look like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE data-set SYSTEM "PDF.dtd" >
<data-set name="PDF">
<element vr="DATE" len="8" name="Date"></element>
<element vr="STRING" len="6" name="Title"></element>
<element vr="STRING" len="6" name="Author"></element>
</data-set>