1

我有以下 XML 子树:

<xdm:Device xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bsi="http://www.hp.com/schemas/imaging/con/bsi/2003/08/21" xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/" xmlns:pwg="http://www.hp.com/schemas/imaging/con/pwg/sm/1.0/" xmlns:xdm="http://www.hp.com/schemas/imaging/con/xdm/1.1/" xmlns:alerts="http://www.hp.com/schemas/imaging/con/alerts/2006/01/13" xmlns:count="http://www.hp.com/schemas/imaging/con/counter/2006/01/13" xmlns:job="http://www.hp.com/schemas/imaging/con/job/2006/01/13" xmlns:media="http://www.hp.com/schemas/imaging/con/media/2006/01/13" xmlns:icd="http://www.hp.com/schemas/imaging/icd/2006/08/27" language="en-US">
    <xdm:Information>
        <dd:ModificationNumber>
            12
        </dd:ModificationNumber>
    </xdm:Information>
</xdm:Device>

我想获得dd:ModificationNumber. 为此,我使用以下 XPath:

/xdm:Device/xdm:Information/dd:ModificationNumber

而这段代码:

TiXmlDocument xmlDoc;
xmlDoc.Parse(xmlSubtree, 0, TIXML_ENCODING_UTF8);
TiXmlElement* xmlElement = xmlDoc.FirstChildElement();
xpath_processor xpathProcessor(xmlElement, xPath);   
expression_result expressionResult = xpathProcessor.er_compute_xpath();
int modificationNumber = expressionResult.i_get_int();

但是,结果表达式是指树的根节点,而不是我预期的 int。并且 modifyNumber 为零。有任何想法吗?

4

0 回答 0