[xml] Problems using xpath with namespaces
- From: "Pedro Rocha" <pedro_jrocha hotmail com>
- To: xml gnome org
- Subject: [xml] Problems using xpath with namespaces
- Date: Thu, 07 Oct 2004 20:22:25 +0200
Hello,
I?ve got the following c++ function (I've removed all the error checking):
long EvaluateXPathExpression (char * FileName, xmlChar * XPathExpression)
{
xmlXPathContextPtr XPathContext;
xmlXPathObjectPtr XPathObject;
// Parse the file.
xmlDocPtr XMLDocumentPtr = xmlParseFile (FileName);
// Initialize the xpath context.
XPathContext = xmlXPathNewContext (XMLDocumentPtr);
// Register all the doc namespaces.
char nameSpace1[] = "http://schemas.xmlsoap.org/soap/envelope/";
char nameSpace1_prefix[] = "soapenv";
char nameSpace2[] =
"http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2";
xmlXPathRegisterNs (XPathContext, (xmlChar*)nameSpace1_prefix,
(xmlChar*)nameSpace1);
xmlXPathRegisterNs (XPathContext, (xmlChar*)"", (xmlChar*)nameSpace2);
// Eval xpath expression.
XPathObject = xmlXPathEvalExpression (XPathExpression, XPathContext);
return 0;
}
And the following xml file:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<SubmitReq
xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">
<MM7Version>5.3.0</MM7Version>
</SubmitReq>
</soapenv:Body>
</soapenv:Envelope>
If I execute EvaluateXPathExpression("filename.xml", "//SubmitReq"), the
xpath evaluation returns no results (XPathObject->nodesetval->nodeTab is
NULL).
Any hints?
Many thanks,
Pedro
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]