Re: [xml] XPath Woes

mt2 wrote:
Hello all,

I'm working on a very simple project to parse ROAP messages, part of
the OMA DRM, for the moment. Libxml2 fits the bill for this project,
so thank you! I am using XPath to query the document:
/roap:riHello/extensions/extension[ xsi:type="roap:CertificateCaching"].
I am trying to get a node returned: <extension
xsi:type="roap:CertificateCaching" />. Unfortunately, I get no results
from libxml, but I have tested this against MSXML and an online XPath
environment. If anyone has any ideas, I'd appreciate it!

I tried your xml file and XPath query using the example program
'xpath1' included in libxml2 distribution, and got the following
results (note that the following command should all be on a single

[bill bbxp work]$ ./xpath1 bug.xml
'/roap:riHello/extensions/extension[ xsi:type="roap:CertificateCaching"]'
Result (1 nodes):
= element node "extension"
[bill bbxp work]$

Perhaps you could analyze what is the difference between your code,
and the way in which this example program behaves (which appears to be

The code:
 xpathCtx = xmlXPathNewContext(doc);
xmlXPathRegisterNs(xpathCtx, (xmlChar *)"roap", (xmlChar
xmlXPathRegisterNs(xpathCtx, (xmlChar *)"xsi", (xmlChar

xpathObj =
xmlXPathEvalExpression("/roap:riHello/extensions/extension[ xsi:type=\"roap:CertificateCaching\"]",

if (xpathObj->nodesetval->nodeNr > 0)

<?xml version="1.0" encoding="utf-8"?>
<roap:riHello xmlns:roap="urn:oma:bac:dldrm:roap-1.0"
xmlns:xsi=""; status="Success"
    <keyIdentifier xsi:type="roap:X509SPKIHash">
    <keyIdentifier xsi:type="roap:X509SPKIHash">
    <keyIdentifier xsi:type="roap:X509SPKIHash">
    <extension xsi:type="roap:CertificateCaching" />


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]