Re: [xml] XPATH question when used with namespace



But with XPATH, when trying to access a particular element nodeset that
is part of a namespace, the only solution I came upon was to use the
contains clause. Is this normal behavior for XPATH or a Gnome feature?

You have two choices. The simpler one, althought it may return a superset of what you want, is to use the local-name() operator

//Envelope-Request/Input-Parmaters/*[local-name()='Dataset']/*[local-name()='Row']

A better method is to create an XPath context, add a {ds, ....} namespace binding into it, and then use that context for search:
  //Envelope-Request/Input-Parameters/ds:Dataset/ds:Row

I don't know the details of adding a namespace binding into an XPath context. A quick search through the docs didn't turn up anything obvious to me. Note that there is nothing special about the "ds" prefix; you could use "FOO", and as long is FOO has the same URI value that "ds" does in the input document, it should work.
        /r$




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