RE: [libxml++] Namespace support in Node::find
- From: Murray Cumming Comneon com
- To: libxmlplusplus-general lists sourceforge net
- Subject: RE: [libxml++] Namespace support in Node::find
- Date: Fri, 23 May 2003 11:13:02 +0200
Thanks. Can we have a test case for this too, please? Maybe you could just
supply an additional example.xml for one of the examples.
Murray Cumming
murrayc usa net
www.murrayc.com
> -----Original Message-----
> From: oystein homelien no [mailto:oystein homelien no]
> Sent: Freitag, 23. Mai 2003 07:55
> To: libxmlplusplus-general lists sourceforge net
> Subject: [libxml++] Namespace support in Node::find
>
>
> I could not get Node::find to properly find things I were
> looking for in a
> document with two namespaces in use. The following patch
> "fixed it". Am
> I missing something, or is this missing in libxml++? (please reply
> directly, i am not on the list)
>
> --- libxml++/nodes/node.cc.orig 2003-05-23
> 07:10:14.806340666 +0200
> +++ libxml++/nodes/node.cc 2003-05-23 07:18:04.733961547 +0200
> @@ -97,6 +97,19 @@
> NodeSet Node::find(const std::string& xpath) const
> {
> xmlXPathContext* ctxt = xmlXPathNewContext(_impl->doc);
> +
> + // make xpath context aware of namespaces
> (oystein powertech no 2003-05-23)
> + int numns = 0;
> + xmlNsPtr *nsl = xmlGetNsList(_impl->doc, _impl);
> + if (nsl) {
> + while (nsl[numns]) {
> + numns++; // count number of nses
> + };
> + };
> +
> + ctxt->namespaces = nsl;
> + ctxt->nsNr = numns;
> +
> ctxt->node = _impl;
> xmlXPathObject* result =
> xmlXPathEval((xmlChar*)xpath.c_str(), ctxt);
>
> @@ -118,6 +131,7 @@
> }
> xmlXPathFreeObject(result);
> xmlXPathFreeContext(ctxt);
> + if (nsl) free(nsl);
>
> return nodes;
> }
>
>
>
> --
> Oystein Homelien, CVO | oystein powertech no
> PowerTech Information Systems AS | http://www.powertech.no/
> Nedre Slottsgate 5, N-0157 OSLO | tel: +47-23-010-010,
> fax: +47-2220-0333
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ObjectStore.
> If flattening out C++ or Java code to make your application fit in a
> relational database is painful, don't do it! Check out ObjectStore.
> Now part of Progress Software. http://www.objectstore.net/sourceforge
> _______________________________________________
> Libxmlplusplus-general mailing list
> Libxmlplusplus-general lists sourceforge net
> https://lists.sourceforge.net/lists/listinfo/libxmlplusplus-general
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]