Re: [xml] XPath Woes

That's very interesting, indeed, because that is exactly the result I
wanted. xpath1.c wasn't included anywhere in my distribution (2.6.32)
that I could find. I found it on the Internet and compiled it against
my built libraries. I ran the command you provided against the file
and got back "Result (0 nodes)". This is very strange, indeed. I'm
pretty sure I have the most recent version of libxml- should I use SVN
instead? I'm using Windows, if that helps provide any sort of answer.
I'm really unsure of where to go from here.

Thank you for you time,

I'm not sure I responded correctly to get this on the mailinglist, so
if not, advice there would be great, too.

On Fri, May 23, 2008 at 8:41 PM, William M. Brack <wbrack mmm com hk> wrote:
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]