#135 closed defect (invalid)
XPath won't select outer element
Reported by: | Dave Abrahams <dave@…> | Owned by: | cmlenz |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | XPath support | Version: | 0.4.2 |
Keywords: | Cc: |
Description
>>> print HTML('<foo>bar</foo>') | Transformer('foo').remove() <foo>bar</foo>
Change History (2)
comment:1 Changed 17 years ago by cmlenz
- Milestone 0.5 deleted
- Resolution set to invalid
- Status changed from new to closed
comment:2 Changed 17 years ago by athomas
As an addendum, '.' is the default selection since r689:
>>> print HTML('<foo>bar</foo>') | Transformer().unwrap() bar
Note: See
TracTickets for help on using
tickets.
This behavior is by design.
When you select from a snippet such as "<foo>bar</foo>", <foo> is the context node for the XPath expression. You would match it with the expression “.”, but the expression “foo” actually tells it to look for any immediate child elements with the tag name “foo”.
I've updated the docstring of Stream.select in r690 to clarify this.