Using library(xpath) operator

I’m using: SWI-Prolog version 8.1.0

I want the code to: use library(xpath) to query xml like xpath(DOM, //foo, Matches).

But what I’m getting is:

ERROR: Syntax error: Operator expected
ERROR: xpath([], /
ERROR: ** here **
ERROR: /foo, C ) . 

My code looks like this:

?- use_module(library(xpath), [xpath/3]).

true.

?- |    xpath([], //foo, C ).
ERROR: Syntax error: Operator expected
ERROR: xpath([], /
ERROR: ** here **
ERROR: /foo, C ) . 

The // needs to be imported as well. This can be done like so:

:- use_module(library(xpath), [xpath/3, op(_, _, //)]).

suspect this is bit rot - operators became per-module a while back

No rot. If you use use_module/1, you get the predicates and operators. If you use use_module/2 you need to tell which predicates and which operators you want, You can use op(_,_,_) to get all operators from a module.

2 Likes