1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-24 21:34:01 +03:00

Feature #2694: Improve ObjectCollection::from_xml_node

It could not parse xml with space between elements
This commit is contained in:
Carlos Martín 2014-02-11 17:20:11 +01:00
parent 9983689e96
commit c026120a17

View File

@ -21,37 +21,33 @@
int ObjectCollection::from_xml_node(const xmlNodePtr node)
{
xmlNodePtr cur_node = 0;
istringstream iss;
int id;
int rc = 0;
ostringstream oss;
for (cur_node = node->children; cur_node != 0; cur_node = cur_node->next)
vector<string>::iterator it;
ObjectXML oxml(node);
oss << "/" << collection_name << "/ID";
vector<string> ids = oxml[oss.str().c_str()];
for (it = ids.begin(); it != ids.end(); it++)
{
if ((cur_node->type == XML_ELEMENT_NODE) &&
(cur_node->children != 0) &&
((cur_node->children->type == XML_TEXT_NODE ) ||
(cur_node->children->type == XML_CDATA_SECTION_NODE)))
{
iss.clear();
iss.str(reinterpret_cast<const char *>(cur_node->children->content));
iss >> dec >> id;
iss.clear();
iss.str(*it);
iss >> dec >> id;
if ( iss.fail() )
{
rc = -1;
break;
}
else
{
collection_set.insert(id);
}
}
else
{
rc = -1;
break;
}
if ( iss.fail() )
{
rc = -1;
break;
}
else
{
collection_set.insert(id);
}
}
return rc;