# Using library(xpath) operator

**URL:** https://swi-prolog.discourse.group/t/using-library-xpath-operator/29
**Category:** Help!
**Created:** [February 4, 2019, 6:13pm UTC](https://swi-prolog.discourse.group/t/using-library-xpath-operator/29 "2019-02-04T18:13:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jamesnvc](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jamesnvc/32/14_2.png) [@jamesnvc](https://swi-prolog.discourse.group/u/jamesnvc)
#### Post date: [February 4, 2019, 6:13pm UTC](https://swi-prolog.discourse.group/t/using-library-xpath-operator/29/1 "2019-02-04T18:13:46Z")

</div>

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:

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

```

My code looks like this:

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

true.

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

```

---

<div class="post-metadata">

### Author: ![jamesnvc](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jamesnvc/32/14_2.png) [@jamesnvc](https://swi-prolog.discourse.group/u/jamesnvc)
#### Post date: [February 4, 2019, 6:14pm UTC](https://swi-prolog.discourse.group/t/using-library-xpath-operator/29/2 "2019-02-04T18:14:51Z")

</div>

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

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

```

---

<div class="post-metadata">

### Author: ![anniepoo](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/anniepoo/32/12_2.png) [@anniepoo](https://swi-prolog.discourse.group/u/anniepoo)
#### Post date: [February 5, 2019, 10:15am UTC](https://swi-prolog.discourse.group/t/using-library-xpath-operator/29/3 "2019-02-05T10:15:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)
#### Post date: [February 5, 2019, 10:50am UTC](https://swi-prolog.discourse.group/t/using-library-xpath-operator/29/4 "2019-02-05T10:50:23Z")

</div>

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.
