Re: [xml] XPath Woes
- From: mt2 <itrekkie gmail com>
- To: "William M. Brack" <wbrack mmm com hk>
- Cc: xml gnome org
- Subject: Re: [xml] XPath Woes
- Date: Tue, 27 May 2008 08:46:19 -0700
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,
Michael
P.S.
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
line):
[bill bbxp work]$ ./xpath1 bug.xml
'/roap:riHello/extensions/extension[ xsi:type="roap:CertificateCaching"]'
"xsi=http://www.w3.org/2001/XMLSchema-instance
roap=urn:oma:bac:dldrm:roap-1.0"
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
correct)?
The code:
xpathCtx = xmlXPathNewContext(doc);
xmlXPathRegisterNs(xpathCtx, (xmlChar *)"roap", (xmlChar
*)"urn:oma:bac:dldrm:roap-1.0");
xmlXPathRegisterNs(xpathCtx, (xmlChar *)"xsi", (xmlChar
*)"http://www.w3.org/2001/XMLSchema-instance");
xpathObj =
xmlXPathEvalExpression("/roap:riHello/extensions/extension[ xsi:type=\"roap:CertificateCaching\"]",
xpathCtx);
if (xpathObj->nodesetval->nodeNr > 0)
XML:
<?xml version="1.0" encoding="utf-8"?>
<roap:riHello xmlns:roap="urn:oma:bac:dldrm:roap-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" status="Success"
sessionId="433211">
<selectedVersion>1.0</selectedVersion>
<riID>
<keyIdentifier xsi:type="roap:X509SPKIHash">
<hash>aXENc+Um/9/NvmYKiHDLaErK0gk</hash>
</keyIdentifier>
</riID>
<riNonce>dsaiuiure9sdwerfqwer</riNonce>
<trustedAuthorities>
<keyIdentifier xsi:type="roap:X509SPKIHash">
<hash>aXENc+Um/9/NvmYKiHDLaErK0gk</hash>
</keyIdentifier>
<keyIdentifier xsi:type="roap:X509SPKIHash">
<hash>aXENc+Um/9/NvmYKiHDLaErK0gk</hash>
</keyIdentifier>
</trustedAuthorities>
<extensions>
<extension xsi:type="roap:CertificateCaching" />
</extensions>
</roap:riHello>
Bill
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]