Created
August 13, 2013 13:22
-
-
Save joshuajnoble/6221014 to your computer and use it in GitHub Desktop.
fixing error in ofXml.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string ofXml::getAttribute(const string& path) const { | |
Poco::XML::Node *e; | |
if(element) { | |
if(path.find("[@") == string::npos) { | |
// we need to create a proper path | |
string attributePath = "[@" + path + "]"; | |
e = element->getNodeByPath(attributePath); | |
} else { | |
e = element->getNodeByPath(path); | |
} | |
} else { | |
ofLogWarning("ofXml") << "getAttribute(): no element set yet"; | |
return ""; | |
} | |
if(e) { | |
return e->getNodeValue(); // this will be the value of the attribute | |
} | |
return ""; | |
} | |
bool ofXml::removeAttribute(const string& path) | |
{ | |
Poco::XML::Element *e; | |
if(element) { | |
// you're *not* using a path | |
if(path.find("[@") == string::npos) { | |
e = element; | |
} else { | |
e = (Poco::XML::Element*) element->getNodeByPath(path); | |
} | |
} else { | |
ofLogWarning("ofXml") << "clearAttributes(): no element set yet"; | |
return false; | |
} | |
if(e) { | |
Poco::XML::NamedNodeMap *map = e->attributes(); | |
for(int i = 0; i < (int)map->length(); i++) { | |
e->removeAttribute(map->item(i)->nodeName()); | |
} | |
map->release(); | |
return true; | |
} | |
return false; | |
} | |
bool ofXml::removeAttributes(const string& path) | |
{ | |
Poco::XML::Element *e; | |
if(element) { | |
if(path.find("[@") == string::npos) { | |
// we need to create a proper path | |
string attributePath = "[@" + path + "]"; | |
e = (Poco::XML::Element*) element->getNodeByPath(attributePath); | |
} else { | |
e = (Poco::XML::Element*) element->getNodeByPath(path); | |
} | |
} else { | |
ofLogWarning("ofXml") << "clearAttributes(): no element set yet"; | |
return false; | |
} | |
if(e) { | |
Poco::XML::NamedNodeMap *map = e->attributes(); | |
for(int i = 0; i < (int)map->length(); i++) { | |
e->removeAttribute(map->item(i)->nodeName()); | |
} | |
map->release(); | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment