[xml] XPath Woes
- From: mt2 <itrekkie gmail com>
- To: xml gnome org
- Subject: [xml] XPath Woes
- Date: Fri, 23 May 2008 15:36:15 -0700
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!
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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]