Обсуждение: xpath and xml namespaces

Поиск
Список
Период
Сортировка

xpath and xml namespaces

От
"Peter Schonefeld"
Дата:
Hi, i'm having trouble getting xpath in Postgres 8.2 to recognise xml namespaces...could someone please point me to a good reference for the xml2 lib?

Cheers
Pete

Re: xpath and xml namespaces

От
"Nikolay Samokhvalov"
Дата:
On 3/4/07, Peter Schonefeld <peter.schonefeld@gmail.com> wrote:
> Hi, i'm having trouble getting xpath in Postgres 8.2 to recognise xml
> namespaces...could someone please point me to a good reference for the xml2
> lib?

This is FAQ-like question.
The thing is that XPath spec doesn't define any default mappings for
namespaces. It's considered as entirely user's problem -- he should
manually define namespaces mappings to use namespace prefixes in XPath
expressions.

If you use contrib/xml2 I'm afraid there is no way to use namespaces
in XPath w/o changing contib's code itself... To enable namespaces
using libxml2 one should use xmlXPathRegisterNs():
http://xmlsoft.org/html/libxml-xpathInternals.html#xmlXPathRegisterNs

I hope 8.3 will have XPath function with namespaces support in core.

--
Best regards,
Nikolay