我已经找到了一种适合我需要的方法。
string executeXPath(xercesc::DOMDocument* doc, string xPathh)
{
const XMLCh* xPath = XMLString::transcode(xPathh.c_str());
int pos = XMLString::indexOf(xPath,'@');
int pos2 = XMLString::indexOf(xPath,('='));
XMLCh* attrName = (XMLCh*)malloc(sizeof(wchar_t)*(pos2-pos));
XMLString::subString(attrName,xPath,pos+1,pos2);
pos = XMLString::indexOf(xPath,'@', pos+1);
XMLCh* attrName2 = (XMLCh*)malloc(sizeof(wchar_t)*(XMLString::stringLen(xPath)-pos));
XMLString::subString(attrName2, xPath, pos+1, XMLString::stringLen(xPath));
pos = XMLString::indexOf(xPath,'"');
XMLCh* attribute = (XMLCh*)malloc(sizeof(wchar_t)*(XMLString::indexOf(xPath,'"',pos+1)-pos));
XMLString::subString(attribute, xPath, pos+1, XMLString::indexOf(xPath,'"',pos+1));
DOMElement* elementRoot = doc->getDocumentElement();
DOMNodeList* nodeList = elementRoot->getElementsByTagName(L"Parameter");
XMLSize_t d = nodeList->getLength();
string valuee = "";
for (XMLSize_t i = 0; i < d; i++)
{
DOMElement* tempElement = (DOMElement*)nodeList->item(i);
if (tempElement->hasAttribute(attrName))
{
const XMLCh* tempChar = tempElement->getAttribute(attrName);
if (XMLString::equals(attribute,tempChar))
{
DOMNodeList* tempList2 = tempElement->getElementsByTagName(L"Values");
DOMElement* tempElement2 = (DOMElement*)tempList2->item(0);
const XMLCh* defValue = tempElement2->getAttribute(attrName2);
valuee = XMLString::transcode(defValue);
break;
}
}
}
delete attrName2;
delete attrName;
delete attribute;
return valuee;
}