Due both to how selection works and how attributes are represented in documents (stored as part of an element, rather than as a separate node) there is no easy way to implement attribute selection, and use of attributes steps are prohibited outside of predicates and will raise an error.
For example, xpath("\\p[@class]") which returns elements with class attributes is allowed, but xpath("\\p\@class") which would return the class attributes themselves is prohibited.
To extract a selected element's attribute use the attr extractor.
PR for issue #85.
Due both to how selection works and how attributes are represented in documents (stored as part of an element, rather than as a separate node) there is no easy way to implement attribute selection, and use of attributes steps are prohibited outside of predicates and will raise an error.
For example,
xpath("\\p[@class]")
which returns elements with class attributes is allowed, butxpath("\\p\@class")
which would return the class attributes themselves is prohibited.To extract a selected element's attribute use the
attr
extractor.