Re: [libxml++] xpath with namespaces



On Mon, Dec 20, 2004 at 12:06:42AM +0100, Murray Cumming wrote:
> I don't know enough about the XPath syntax to know whether this should
> work. Could someone attach a test case (not a URL) in bugzilla, if we
> don't make progress here.
> 
> 
> On Mon, 2004-12-06 at 13:36 -0800, Curtis Spencer wrote:
> > I am able to successfully parse the file using both the DOMParser and
> > the SaxParser, so I don't believe there is an error.  If you want to
> > take a look at the file it is at:
> > 
> > http://www.gentoo.org/rdf/en/glsa-index.rdf
> [snip]
> > > >  I"m trying to use XPaths on documents which use namespaces (e.g.
> > > >  libxml++-2.6.1/examples/sax_exception/example.xml). My code looks like this:
> > > >
> > > >  xmlpp::DomParser dp;
> > > >  dp.parse_file("example.xml");
> > > >  xmlpp::Document* doc = dp.get_document();
> > > >  xmlpp::Element* root = doc->get_root_node();
> > > >  xmlpp::NodeSet set = root->find("//gjob:Jobs");
> > > >
> > > >  If I use "//gjob:Jobs" i get "XPath error : Undefined namespace prefix",
> > > >  and "//Jobs" just returns an empty set.

  Perfectly normal, the expression uses the gjob prefix and it was not
registered.

> > > >  I assume I have to register the namespace first, but I couldn"t find
> > > >  anything about this in the documentation.

  http://xmlsoft.org/html/libxml-xpathInternals.html#xmlXPathRegisterNs
  at the C level, it may not be available in libxml++

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]