sschwarzer
2022-2-12 18:29:53

I’m trying to use xml/path (https://docs.racket-lang.org/xml/index.html#%28mod-path._xml%2Fpath%29) to access data in an xexpr, but I can’t find out the valid syntax for an se-path in se-path*/list. Specifically, I want to find a div that has a class="description". Any ideas?


soegaard2
2022-2-12 18:32:17

I don’t know if it is helpful or not, but here are some results from Github: https://github.com/search?q=%22se-path*%22&type=code


sorawee
2022-2-12 18:36:06

I think if you really want to use this, you would query to find all '(div), and filter for those with the desired class.


sorawee
2022-2-12 18:36:25

It’s called “Simple X-expression Path Queries” for a reason :slightly_smiling_face:


sschwarzer
2022-2-12 18:41:50

> find all '(div), and filter for those with the desired class. Yes, that could be a workaround I thought of.


sschwarzer
2022-2-12 18:44:11

sschwarzer
2022-2-12 18:47:39

Even (xexpr-path-list '(div) e2) (where e2 is my document) returns an empty list, though the document has plenty of divs in it. But since the example for xexpr-path-list (xexpr-path-list '(greeting) '(greetings (greeting "Hello World!") (greeting "Ahoj Světe!"))) works, I suspect you have to provide the full “tail” of the path (i.e. further down than just the div).


sorawee
2022-2-12 18:51:04

oh yeah


notjack
2022-2-12 22:14:11

I think it would, but if that’s infeasible it should definitely emit a warning of some kind