//--------------------------------------------------------- bool ofxXmlSettings::attributeExists(const string& tag, const string& attribute, int which) { vector<string> tokens = tokenize(tag,":"); TiXmlHandle tagHandle = storedHandle; for (int x = 0; x < tokens.size(); x++) { if (x == 0) tagHandle = tagHandle.ChildElement(tokens.at(x), which); else tagHandle = tagHandle.FirstChildElement(tokens.at(x)); } if (tagHandle.ToElement()) { TiXmlElement* elem = tagHandle.ToElement(); // Do stuff with the element here for (TiXmlAttribute* a = elem->FirstAttribute(); a; a = a->Next()) { if (a->Name() == attribute) return true; } } return false; }
daeElementRef daeTinyXMLPlugin::readElement(TiXmlElement* tinyXmlElement, daeElement* parentElement) { std::vector<attrPair> attributes; for (TiXmlAttribute* attrib = tinyXmlElement->FirstAttribute(); attrib != NULL; attrib = attrib->Next()) attributes.push_back(attrPair(attrib->Name(), attrib->Value())); daeElementRef element = beginReadElement(parentElement, tinyXmlElement->Value(), attributes, getCurrentLineNumber(tinyXmlElement)); if (!element) { // We couldn't create the element. beginReadElement already printed an error message. return NULL; } if (tinyXmlElement->GetText() != NULL) readElementText(element, tinyXmlElement->GetText(), getCurrentLineNumber(tinyXmlElement)); // Recurse children for (TiXmlElement* child = tinyXmlElement->FirstChildElement(); child != NULL; child = child->NextSiblingElement()) element->placeElement(readElement(child, element)); return element; }
void TiXmlElement::CopyTo( TiXmlElement* target ) const { // superclass: TiXmlNode::CopyTo( target ); // Element class: // Clone the attributes, then clone the children. TiXmlAttribute* attribute = 0; for( attribute = attributeSet.First(); attribute; attribute = attribute->Next() ) { target->SetAttribute( attribute->Name(), attribute->Value() ); } TiXmlNode* node = 0; for ( node = firstChild; node; node = node->NextSibling() ) { target->LinkEndChild( node->Clone() ); } }
bool AgentInitializer::parsePropertySpec( TiXmlElement * node ) { if ( node->ValueStr() == "Property" ) { const char * cName = node->Attribute( "name" ); if ( cName == 0x0 ) { logger << Logger::ERR_MSG << "AgentSet Property tag specified on line " << node->Row() << " without a \"name\" attribute."; return false; } ::std::string propName( cName ); return processProperty( propName, node ) != FAILURE; } else if ( VERBOSE ) { logger << Logger::WARN_MSG << "Unexpected tag when looking for a property of an AgentSet parameter set: " << node->ValueStr() << "\n"; TiXmlAttribute * attr; for ( attr = node->FirstAttribute(); attr; attr = attr->Next() ) { if ( setFromXMLAttribute( attr->Name(), attr->ValueStr() ) == FAILURE ) { return false; } } } // Unexpected tags are ignored return true; }
int XmlUtils::getIntAttribute(const TiXmlElement* element, const char* name, int def) { TiXmlAttribute* attribute = element->GetAttribute(name); if (attribute == nullptr) return def; const std::string& string = attribute->ValueStr(); try { size_t pos = 0; int value = std::stoi(string, &pos); if (pos == string.length()) return value; } catch (const std::exception& e) { B3D_LOGE(locationOf(element) << "Value of attribute \"" << name << "\" is not a valid integer (" << e.what() << ")."); throw ParseError(); } B3D_LOGE(locationOf(element) << "Value of attribute \"" << name << "\" is not a valid integer."); throw ParseError(); }
void CRedisProxyCfg::getVipAttr(const TiXmlElement* vidNode) { TiXmlAttribute *addrAttr = (TiXmlAttribute *)vidNode->FirstAttribute(); for (; addrAttr != NULL; addrAttr = addrAttr->Next()) { const char* name = addrAttr->Name(); const char* value = addrAttr->Value(); if (value == NULL) value = ""; if (0 == strcasecmp(name, "if_alias_name")) { strcpy(m_vip.if_alias_name, value); continue; } if (0 == strcasecmp(name, "vip_address")) { strcpy(m_vip.vip_address, value); continue; } if (0 == strcasecmp(name, "enable")) { if(strcasecmp(value, "0") != 0 && strcasecmp(value, "") != 0 ) { m_vip.enable = true; } } } }
//----------------------------------------------------------------------------- bool xml_c::process_tixml_element( void* tixml_element, xml_element_ptr element ) { // TODO: robust error checking TiXmlElement* tixml_e = (TiXmlElement*) tixml_element; const char* pkey = tixml_e->Value(); const char* ptext = tixml_e->GetText(); element->set_name( pkey ); if( ptext ) element->set_value( ptext ); TiXmlAttribute* a = tixml_e->FirstAttribute(); while( a!= NULL ) { std::string name = a->Name(); std::string value = a->Value(); xml_attribute_ptr attrib = xml_attribute_ptr( new xml_attribute_c() ); attrib->set_name( a->Name() ); attrib->set_value( a->Value() ); element->append( attrib ); a = a->Next(); } TiXmlElement* tixml_child; for( tixml_child = tixml_e->FirstChildElement(); tixml_child != NULL; tixml_child = tixml_child->NextSiblingElement() ) { xml_element_ptr child = xml_element_ptr( new xml_element_c() ); element->append( child ); process_tixml_element( tixml_child, child ); } return true; }
bool Rule::LoadFromXml(TiXmlElement *node) { TiXmlAttribute *attr = node->ToElement()->FirstAttribute(); for (; attr; attr = attr->Next()) { if (string(attr->Name()) != "name" && string(attr->Name()) != "type") params.Add(attr->Name(), attr->ValueStr()); } TiXmlElement *cnode = node->FirstChildElement(); for (; cnode; cnode = cnode->NextSiblingElement()) { if (cnode->ValueStr() == "calaos:condition") { Condition *cond = RulesFactory::CreateCondition(cnode); if (cond) AddCondition(cond); } else if (cnode->ValueStr() == "calaos:action") { Action *action = RulesFactory::CreateAction(cnode); if (action) AddAction(action); } } return true; }
SmartPointer<RobotController> RobotControllerFactory::Load(TiXmlElement* in,Robot& robot) { if(0!=strcmp(in->Value(),"controller")) { fprintf(stderr,"Controller does not have type \"controller\", got %s\n",in->Value()); return NULL; } if(in->Attribute("type")==NULL) { fprintf(stderr,"Controller does not have \"type\" attribute\n"); return NULL; } SmartPointer<RobotController> c = CreateByName(in->Attribute("type"),robot); if(!c) { fprintf(stderr,"Unable to load controller of type %s\n",in->Attribute("type")); fprintf(stderr,"Candidates: \n"); for(map<std::string,SmartPointer<RobotController> >::iterator i=controllers.begin();i!=controllers.end();i++) fprintf(stderr," %s\n",i->first.c_str()); return NULL; } TiXmlAttribute* attr = in->FirstAttribute(); while(attr != NULL) { if(0==strcmp(attr->Name(),"type")) { attr = attr->Next(); continue; } if(!c->SetSetting(attr->Name(),attr->Value())) { fprintf(stderr,"Load controller %s from XML: Unable to set setting %s\n",in->Attribute("type"),attr->Name()); return NULL; } attr = attr->Next(); } return c; }
int xmlStructure::dump_attribs_to_stdout ( TiXmlElement* pElement, unsigned int indent ) { if ( !pElement ) return 0; TiXmlAttribute* pAttrib = pElement->FirstAttribute(); int i = 0; int ival; double dval; const char* pIndent = getIndent ( indent ); printf ( "\n" ); while ( pAttrib ) { printf ( "%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value() ); if ( pAttrib->QueryIntValue ( &ival ) == TIXML_SUCCESS ) printf ( " int=%d", ival ); if ( pAttrib->QueryDoubleValue ( &dval ) == TIXML_SUCCESS ) printf ( " d=%1.1f", dval ); printf ( "\n" ); i++; pAttrib = pAttrib->Next(); } return i; }
bool CConverToMK::ParseFilterInVCProjectFile( TiXmlElement* pkElement, StringVector& kVector) { if (0 == pkElement) { return false; } TiXmlElement* pkFilter = pkElement->FirstChildElement(); if (0 == pkFilter) { return false; } do { TiXmlAttribute* pkAttr = pkFilter->FirstAttribute(); string strType = pkFilter->Value(); if (strcmp("Filter",strType.c_str()) == 0) { ParseFilterInVCProjectFile(pkFilter,kVector); } else if (strcmp("File",strType.c_str()) == 0) { string strName = pkAttr->Value(); if (!IsFilterWord(strName.c_str())) { continue; } kVector.push_back(strName); } } while (pkFilter = pkFilter->NextSiblingElement()); return true; }
void CUICommandNode::RemoveSameProperty(TiXmlNode* pBeforeElem, TiXmlNode* pAfterElem) { TiXmlAttribute* pBeforeAttrib = pBeforeElem->ToElement()->FirstAttribute(); TiXmlAttribute* pAfterAttrib = pAfterElem->ToElement()->FirstAttribute(); while(pBeforeAttrib) { TiXmlAttribute* pBeforeAttribNext = pBeforeAttrib->Next(); TiXmlAttribute* pAfterAttribNext = pAfterAttrib->Next(); if(strcmp(pBeforeAttrib->Name(), "name")!=0 && strcmp(pBeforeAttrib->Value(), pAfterAttrib->Value())==0) { pBeforeElem->ToElement()->RemoveAttribute(pBeforeAttrib->Name()); pAfterElem->ToElement()->RemoveAttribute(pAfterAttrib->Name()); } pBeforeAttrib = pBeforeAttribNext; pAfterAttrib = pAfterAttribNext; } }
void CGUIIncludes::ResolveExpressions(TiXmlElement *node) { if (!node) return; TiXmlNode *child = node->FirstChild(); if (child && child->Type() == TiXmlNode::TINYXML_TEXT && m_expressionNodes.count(node->ValueStr())) { child->SetValue(ResolveExpressions(child->ValueStr())); } else { TiXmlAttribute *attribute = node->FirstAttribute(); while (attribute) { if (m_expressionAttributes.count(attribute->Name())) attribute->SetValue(ResolveExpressions(attribute->ValueStr())); attribute = attribute->Next(); } } }
bool CButtonTranslator::LoadLircMap() { // load our xml file, and fill up our mapping tables TiXmlDocument xmlDoc; // Load the config file CStdString lircmapPath = g_settings.GetUserDataItem("Lircmap.xml"); CLog::Log(LOGINFO, "Loading %s", lircmapPath.c_str()); if (!xmlDoc.LoadFile(lircmapPath)) { g_LoadErrorStr.Format("%s, Line %d\n%s", lircmapPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); return true; // This is so people who don't have the file won't fail, just warn } lircRemotesMap.clear(); TiXmlElement* pRoot = xmlDoc.RootElement(); CStdString strValue = pRoot->Value(); if (strValue != "lircmap") { g_LoadErrorStr.Format("%sl Doesn't contain <lircmap>", lircmapPath.c_str()); return false; } // run through our window groups TiXmlNode* pRemote = pRoot->FirstChild(); while (pRemote) { const char *szRemote = pRemote->Value(); if (szRemote) { TiXmlAttribute* pAttr = pRemote->ToElement()->FirstAttribute(); const char* szDeviceName = pAttr->Value(); MapRemote(pRemote, szDeviceName); } pRemote = pRemote->NextSibling(); } return true; }
void SE_ShaderHandler::handle(SE_Element* parent, TiXmlElement* xmlElement, unsigned int indent) { if(!xmlElement) return; TiXmlAttribute* pAttribute = xmlElement->FirstAttribute(); SE_ResourceManager* resourceManager = SE_Application::getInstance()->getResourceManager(); std::string vertexShaderFilePath; std::string fragmentShaderFilePath; while(pAttribute) { const char* name = pAttribute->Name(); const char* value = pAttribute->Value(); if(!strcmp(name , "VertexShader")) { vertexShaderFilePath = std::string(resourceManager->getDataPath()) + SE_SEP + value; } else if(!strcmp(name, "FragmentShader")) { fragmentShaderFilePath = std::string(resourceManager->getDataPath()) + SE_SEP + value; } pAttribute = pAttribute->Next(); } char* vertexShader; char* fragmentShader; int vertexShaderLen =0; int fragmentShaderLen = 0; SE_IO::readFileAll(vertexShaderFilePath.c_str(), vertexShader, vertexShaderLen); SE_IO::readFileAll(fragmentShaderFilePath.c_str(), fragmentShader, fragmentShaderLen); char* vs = new char[vertexShaderLen + 1]; char* fs = new char[fragmentShaderLen + 1]; memset(vs, 0, vertexShaderLen + 1); memset(fs, 0, fragmentShaderLen + 1); memcpy(vs, vertexShader, vertexShaderLen); memcpy(fs, fragmentShader, fragmentShaderLen); SE_ProgramDataID id("main_vertex_shader"); //resourceManager->setShaderProgram(id, vs, fs); delete[] vertexShader; delete[] fragmentShader; }
void CRedisProxyCfg::setKeyMappingNode(TiXmlElement* pNode) { TiXmlElement* pNext = pNode->FirstChildElement(); for (; pNext != NULL; pNext = pNext->NextSiblingElement()) { CKeyMapping hashMap; if (0 == strcasecmp(pNext->Value(), "key")) { TiXmlAttribute *addrAttr = pNext->FirstAttribute(); for (; addrAttr != NULL; addrAttr = addrAttr->Next()) { const char* name = addrAttr->Name(); const char* value = addrAttr->Value(); if (value == NULL) value = ""; if (0 == strcasecmp(name, "key_name")) { strcpy(hashMap.key, value); continue; } if (0 == strcasecmp(name, "group_name")) { strcpy(hashMap.group_name, value); } } m_keyMappingList->push_back(hashMap); } } }
View* XmlParser::parse_element(TiXmlElement *e, View *parent /* = NULL */) { if (!e) { return NULL; } View *view = ResourceCreator::instance().get_view(e->Value()); if (!view) { return NULL; } if (parent) { view->set_parent(parent); parent->push_child(view); } TiXmlAttribute *a = e->FirstAttribute(); PropMap props; while(a) { props.insert(make_pair(a->Name(), a->Value())); a = a->Next(); } view->parse(props); TiXmlNode *node = e->FirstChild(); if (!node) { return view; } TiXmlElement *sub = node->ToElement(); while (sub) { View* sv = parse_element(sub, view); sub = sub->NextSiblingElement(); } return view; }
inline bool TamlXmlParser::parseAttributes( TiXmlElement* pXmlElement, TamlVisitor& visitor ) { // Debug Profiling. PROFILE_SCOPE(TamlXmlParser_ParseAttribute); // Calculate if element is at the root or not. const bool isRoot = pXmlElement->GetDocument()->RootElement() == pXmlElement; // Create a visitor property state. TamlVisitor::PropertyState propertyState; propertyState.setObjectName( pXmlElement->Value(), isRoot ); // Iterate attributes. for ( TiXmlAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() ) { // Configure property state. propertyState.setProperty( pAttribute->Name(), pAttribute->Value() ); // Visit this attribute. const bool visitStatus = visitor.visit( *this, propertyState ); // Was the property value changed? if ( propertyState.getPropertyValueDirty() ) { // Yes, so update the attribute. pAttribute->SetValue( propertyState.getPropertyValue() ); // Flag the document as dirty. mDocumentDirty = true; } // Finish if requested. if ( !visitStatus ) return false; } return true; }
/*! * /brief 通过节点查询。 * * /param XmlFile xml文件全路径。 * /param strNodeName 要查询的节点名 * /param AttMap 要查询的属性值,这是一个map,前一个为属性名,后一个为属性值 * /return 是否成功。true为成功,false表示失败。 */ bool xml_QueryNode_Attribute(TiXmlElement *pRootEle, std::string strNodeName, std::map<std::string, std::string> &AttMap) { // 定义一个TiXmlDocument类指针 typedef std::pair<std::string, std::string> String_Pair; if (NULL == pRootEle) { return false; } TiXmlElement *pNode = NULL; xml_GetNodePointerByName(pRootEle, strNodeName, pNode); if (NULL != pNode) { TiXmlAttribute* pAttr = NULL; for (pAttr = pNode->FirstAttribute(); pAttr; pAttr = pAttr->Next()) { std::string strAttName = pAttr->Name(); std::string strAttValue = pAttr->Value(); AttMap.insert(String_Pair(strAttName, strAttValue)); } return true; } else { return false; } return true; }
int em::EmXml::ReadRootAttrMap( EmMapStr &rMapStr ) { int iResult = 0; rMapStr.clear(); TiXmlElement *pElemRoot = m_pDoc->RootElement(); if(pElemRoot == NULL) { return 0; } TiXmlAttribute *pAttr = pElemRoot->FirstAttribute(); while(true) { if(pAttr == NULL) { break; } rMapStr[ pAttr->Name() ] = pAttr->Value() ; pAttr = pAttr->Next(); } iResult = rMapStr.size(); return iResult; }
void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) { TIXML_STRING _name( cname ); TIXML_STRING _value( cvalue ); TiXmlAttribute* node = attributeSet.Find( _name ); if ( node ) { node->SetValue( cvalue ); return; } TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); if ( attrib ) { attributeSet.Add( attrib ); } else { TiXmlDocument* document = GetDocument(); if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); } }
void CALLBACK CUICommandHistory::UIModify(TiXmlNode* pNode) { TiXmlElement* pElement = pNode->ToElement(); CStringA strName = pElement->Attribute("name"); pElement->RemoveAttribute("name"); if(strName.IsEmpty()) return; CPaintManagerUI* pManager = g_pMainFrame->GetActiveUIView()->GetPaintManager(); CControlUI* pControl = pManager->FindControl(StringConvertor::Utf8ToWide(strName)); TiXmlAttribute* pAttrib = pElement->FirstAttribute(); if(pControl == NULL) return; while(pAttrib) { pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name()) , StringConvertor::Utf8ToWide(pAttrib->Value())); pAttrib = pAttrib->Next(); } CControlUI* pParent = pControl->GetParent(); pParent->SetPos(pParent->GetPos()); }
void TiXmlElement::SetAttribute(const std::string &name, const std::string &_value) { TiXmlAttribute *node = attributeSet.Find(name); if (node) { node->SetValue(_value); return ; } TiXmlAttribute *attrib = new TiXmlAttribute(name, _value); if (attrib) { attributeSet.Add(attrib); } else { TiXmlDocument *document = GetDocument(); if (document) { document->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN); } } }
/*********************************************************************************************************** * 程序作者:赵进军 * 函数功能:获取 XML文件所有的数据 * 参数说明:null * 注意事项:null * 修改日期:2015/12/14 23:10:00 ***********************************************************************************************************/ void OperationProfile_XML::GetXmlDataAll(TiXmlNode* pRootEle, char* groupName) { if (NULL == pRootEle) return; TiXmlNode* pElement = pRootEle->FirstChild(); TiXmlElement* element; TiXmlAttribute* attr; int kl; for (; pElement; pElement = pElement->NextSibling()) { int nType = pElement->Type(); switch (nType) { case TiXmlNode::TINYXML_ELEMENT: element = pElement->ToElement(); if (element != NULL) { attr = element->FirstAttribute(); if (attr != NULL) std::cout << attr->Value() << std::endl; } GetXmlDataAll(pElement, groupName); break; case TiXmlNode::TINYXML_TEXT: std::cout << pElement->Value() << std::endl; break; case TiXmlNode::TINYXML_DOCUMENT: kl = 0; break; default: break; } } }
// static member function HeeksObj* CAdaptive::ReadFromXMLElement(TiXmlElement* element) { CAdaptive* new_object = new CAdaptive; std::list<TiXmlElement *> elements_to_remove; // read solid and sketch ids for(TiXmlElement* pElem = heeksCAD->FirstXMLChildElement( element ) ; pElem; pElem = pElem->NextSiblingElement()) { std::string name(pElem->Value()); if(name == "params"){ new_object->m_params.ReadFromXMLElement(pElem); elements_to_remove.push_back(pElem); } else if(name == "solid"){ for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next()) { std::string name(a->Name()); if(name == "id"){ int id = a->IntValue(); new_object->m_solids.push_back(id); } } elements_to_remove.push_back(pElem); } else if(name == "sketch"){ for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next()) { std::string name(a->Name()); if(name == "id"){ int id = a->IntValue(); new_object->m_sketches.push_back(id); } } elements_to_remove.push_back(pElem); } } for (std::list<TiXmlElement*>::iterator itElem = elements_to_remove.begin(); itElem != elements_to_remove.end(); itElem++) { heeksCAD->RemoveXMLChild( element, *itElem); } new_object->ReadBaseXML(element); return new_object; }
void TiXmlElement::Print( FILE* fp, int depth ) { int i; for ( i=0; i<depth; i++ ) fprintf( fp, " " ); fprintf( fp, "<%s", value.c_str() ); TiXmlAttribute* attrib; for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) { fprintf( fp, " " ); attrib->Print( fp, 0 ); } // If this node has children, give it a closing tag. Else // make it an empty tag. TiXmlNode* node; if ( firstChild ) { fprintf( fp, ">" ); for ( node = firstChild; node; node=node->NextSibling() ) { if ( !node->ToText() ) fprintf( fp, "\n" ); node->Print( fp, depth+1 ); } fprintf( fp, "\n" ); for ( i=0; i<depth; i++ ) fprintf( fp, " " ); fprintf( fp, "</%s>", value.c_str() ); } else { fprintf( fp, " />" ); } }
TiXmlNode* TiXmlElement::Clone() const { TiXmlElement* clone = new TiXmlElement( Value() ); if ( !clone ) return 0; CopyToClone( clone ); // Clone the attributes, then clone the children. TiXmlAttribute* attribute = 0; for( attribute = attributeSet.First(); attribute; attribute = attribute->Next() ) { clone->SetAttribute( attribute->Name(), attribute->Value() ); } TiXmlNode* node = 0; for ( node = firstChild; node; node = node->NextSibling() ) { clone->LinkEndChild( node->Clone() ); } return clone; }
void CKSXML_Read_Project::Read_Master_Aux_Return(TiXmlElement* pElement) { if ( !pElement ) return ; TiXmlAttribute* pAttrib = pElement->FirstAttribute(); tint32 ival; // aux id if (pAttrib->QueryIntValue(&ival)==TIXML_SUCCESS) ;//printf( "AUX %d return: ", ival); TiXmlNode* pChild; for ( pChild = pElement->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) { if(pChild->Type() == TiXmlNode::ELEMENT){ if (stricmp("volume", pChild->Value()) == 0) { Set_DAW_Parameter(pChild, giTinyXml_Type_Float, 0, 0); } } } }
void readXml() { TiXmlDocument* myDocument = new TiXmlDocument(); myDocument->LoadFile("student.xml"); myDocument->Print(); TiXmlElement* rootElement = myDocument->RootElement(); //Class TiXmlElement* studentsElement = rootElement->FirstChildElement(); //Students TiXmlElement* studentElement = studentsElement->FirstChildElement(); //Students //std::cout<<studentElement->GetText() ; while ( studentElement ) { TiXmlAttribute* attributeOfStudent = studentElement->FirstAttribute(); //获得student的name属性 while ( attributeOfStudent ) { std::cout << attributeOfStudent->Name() << " : " << attributeOfStudent->Value() << std::endl; attributeOfStudent = attributeOfStudent->Next(); } TiXmlElement* phoneElement = studentElement->FirstChildElement();//获得student的phone元素 std::cout << "phone" << " : " << phoneElement->GetText() << std::endl; TiXmlElement* addressElement = phoneElement->NextSiblingElement(); std::cout << "address" << " : " << phoneElement->GetText() << std::endl; studentElement = studentElement->NextSiblingElement(); } }
//--------------------------------------------------------- int ofxXmlSettings::getNumAttributes(const string& tag, int which){ vector<string> tokens = tokenize(tag,":"); TiXmlHandle tagHandle = storedHandle; for (int x = 0; x < (int)tokens.size(); x++) { if (x == 0) tagHandle = tagHandle.ChildElement(tokens.at(x), which); else tagHandle = tagHandle.FirstChildElement(tokens.at(x)); } if (tagHandle.ToElement()) { TiXmlElement* elem = tagHandle.ToElement(); // Do stuff with the element here TiXmlAttribute* first = elem->FirstAttribute(); if (first) { int count = 1; for (TiXmlAttribute* curr = first; curr != elem->LastAttribute(); curr = curr->Next()) count++; return count; } } return 0; }