connect
connect copied to clipboard
bloblang method for XPath
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)
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 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