bool XMLReader::ForceReadAttribute(const XMLElement aElementToReadFrom, const std::string& aAttributeToRead, std::string& aTargetVariable) const { if (myHasOpenedDoc == false) DL_ASSERT("[XMLReader]: Tried to [ForceReadAttribute(string)] before Opening the document"); if (aElementToReadFrom->FindAttribute(aAttributeToRead.c_str()) != 0) { aTargetVariable = aElementToReadFrom->Attribute(aAttributeToRead.c_str()); return true; } DL_DEBUG("Failed to read Attribute: [ %s ], from Element: [ %s ], in Document: [ %s ]", aAttributeToRead.c_str(), aElementToReadFrom->Name(), myFilePath.c_str()); DL_ASSERT("Failed to [ForceReadAttribute(string)], check DebugLog for more info"); return false; }
bool XMLReader::ReadAttribute(const XMLElement aElementToReadFrom, const std::string& aAttributeToRead, std::string& aTargetVariable) const { if (myHasOpenedDoc == false) DL_ASSERT("[XMLReader]: Tried to [ReadAttribute(string)] before Opening the document"); if (aElementToReadFrom == nullptr) return false; if (aElementToReadFrom->FindAttribute(aAttributeToRead.c_str()) != 0) { aTargetVariable = aElementToReadFrom->Attribute(aAttributeToRead.c_str()); return true; } return false; }
void ConfigParser::locateElement() { if (pParent != 0) { for (int i=0; i<pParent->pElement->GetChildrenCount(); i++) { XMLElement *pElem = pParent->pElement->GetChild(i); if (pElem->GetName().Equals(sElemName)) { if (lID == -1) { pElement = pElem; return; } else { XMLAttribute *pAttr = pElem->FindAttribute("id"); if (pAttr) { if (pAttr->GetValue().ToLong() == lID) { pElement = pElem; return; } } } } } pElement = pParent->addChild(sElemName); if (-1 != lID) { pElement->AddAttribute("id", lID); } } }