本文整理汇总了C++中DOMParser::parseMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMParser::parseMemory方法的具体用法?C++ DOMParser::parseMemory怎么用?C++ DOMParser::parseMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMParser
的用法示例。
在下文中一共展示了DOMParser::parseMemory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseResponseEeml
bool ofxXivelyOutput::parseResponseEeml(string _response) {
if (bVerbose) printf("[Xively] start parsing eeml\n");
try
{
pData.clear();
DOMParser parser;
AttrMap* pMap;
AutoPtr<Document> pDoc = parser.parseMemory(_response.c_str(), _response.length());
NodeIterator itElem(pDoc, NodeFilter::SHOW_ELEMENT);
Node* pNode = itElem.nextNode();
while (pNode)
{
if (pNode->nodeName() == XMLString("environment"))
{
pMap = (AttrMap*) pNode->attributes();
sUpdated = pMap->getNamedItem("updated")->nodeValue();
}
if (pNode->nodeName() == XMLString("title"))
sTitle = pNode->firstChild()->getNodeValue();
if (pNode->nodeName() == XMLString("status"))
sStatus = pNode->firstChild()->getNodeValue();
if (pNode->nodeName() == XMLString("description"))
sDescription = pNode->firstChild()->getNodeValue();
if (pNode->nodeName() == XMLString("website"))
sWebsite = pNode->firstChild()->getNodeValue();
if (pNode->nodeName() == XMLString("location"))
{
// pMap = (AttrMap*)pNode->attributes();
// location.sDomain = pMap->getNamedItem("domain")->nodeValue();
// location.sExposure = pMap->getNamedItem("exposure")->nodeValue();
// location.sDisposition = pMap->getNamedItem("disposition")->nodeValue();
NodeIterator itChildren(pNode, NodeFilter::SHOW_ELEMENT);
Node* pChild = itChildren.nextNode();
while (pChild)
{
if (pChild->nodeName() == XMLString("name"))
location.sName = pChild->firstChild()->nodeValue();
if (pChild->nodeName() == XMLString("lat"))
location.sLat = pChild->firstChild()->nodeValue();
if (pChild->nodeName() == XMLString("lon"))
location.sLon = pChild->firstChild()->nodeValue();
pChild = itChildren.nextNode();
}
}
if (pNode->nodeName() == XMLString("data"))
{
ofxXivelyData data;
pMap = (AttrMap*) pNode->attributes();
data.iId = atoi(pMap->getNamedItem("id")->nodeValue().c_str());
NodeIterator itChildren(pNode, NodeFilter::SHOW_ELEMENT);
Node* pChild = itChildren.nextNode();
while (pChild)
{
if (pChild->nodeName() == XMLString("tag"))
data.pTags.push_back(pChild->firstChild()->getNodeValue());
if (pChild->nodeName() == XMLString("value"))
{
data.fValue = atof(pChild->firstChild()->getNodeValue().c_str());
pMap = (AttrMap*) pChild->attributes();
data.fValueMin = atof(pMap->getNamedItem("minValue")->nodeValue().c_str());
data.fValueMax = atof(pMap->getNamedItem("maxValue")->nodeValue().c_str());
}
pChild = itChildren.nextNode();
}
pData.push_back(data);
}
pNode = itElem.nextNode();
}
}
catch (Exception& exc)
{
printf("[Xively] Parse xml exception: %s\n", exc.displayText().c_str());
return false;
}
if (bVerbose) printf("[Xively] finished parsing eeml\n");
return true;
}