Q: xmerl 0.15 xpath fails to match the following - why?

Ulf Wiger <>
Wed Oct 17 09:48:31 CEST 2001


I've never really used XPATH myself... I only wrote the code
based on the spec, and tried to run some fake tests... :-/

I remember that Mickael Remond highlighted the fact that XPATH
didn't represent the root node properly. The somewhat cludgy
solution was to have XPATH wrap the XML structure returned by
xmerl_scan with an #xmerlDocument{} (or similar) record.

Perhaps Mickael has some good examples of how to use XPATH?
(I know ESoap uses it.)

I'm sorry I can't be more helpful.

/Uffe

On Tue, 16 Oct 2001, Reto Kramer wrote:

>I'm using xmerl 0.15 and tried out the xpath matcher with the example below.
>
>Unfortunately the xpath does not match and returns an empty list. The same
>happens with e.g. /document.
>
>D: {xmlElement,document, ...
>    ... the long form of the xml tree ...
>X: []
>ok
>
>Does anyone have a test-set for xmerl xpath, so I can mimic the successful
>use of it?
>
>cheers,
>- Reto
>
>foo2() ->
>    D = xmerl_scan:string(string()),
>    io:format("D :~p~n",[D]),
>    X = xmerl_xpath:string("/document/section/section/table/row", D),
>    io:format("X :~p~n",[X]).
>
>
>string() ->
>     "<document title=\"Doc Title\"
>          author=\"Ulf Wiger\">
><section heading=\"heading1\">
><P>
>This is a paragraph of text.
></P>
><section heading=\"heading2\">
><P>
>This is another paragraph.
></P>
><table border=\"1\">
><heading>
><col>
>head1
></col>
><col>
>head2
></col>
></heading>
><row>
><col>
>col11
></col>
><col>
>col12
></col>
></row>
><row>
><col>
>col21
></col>
><col>
>col22
></col>
></row>
></table>
></section>
></section>
></document>
>".
>
>

-- 
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB




More information about the erlang-questions mailing list