connect icon indicating copy to clipboard operation
connect copied to clipboard

bloblang method for XPath

Open sascha-andres opened this issue 2 years ago • 2 comments

It'd be nice if I could read elements out of an XML document using xpath. Something like this:

- bloblang: root.id = content().xpath(/element/id)
- bloblang: root.value = content().xpath(/element/value)
- bloblang: root.meta.created = content().xpath(/element/creation)

sascha-andres avatar May 18 '22 13:05 sascha-andres

Hey @sascha-andres, sounds like a reasonable addition. We'd need to decide whether this method would only be applicable to an XML document in string/bytes format, or whether we'd allow it generally on structured data. I think we'd need to restrict ourselves to the former in order to have clear deterministic behaviour.

Jeffail avatar May 19 '22 17:05 Jeffail

@Jeffail I'd propose adding this to XML only. Xpath is quite specific to that. For other formats there are other commonly in use query languages (eg what jq uses).

One could probably think of an html2xml sanitizer as a pipeline step to clean up badly when websites

sascha-andres avatar May 19 '22 18:05 sascha-andres