Ticket #271 (new defect)
Opened 7 weeks ago
XPath gets lost when indexing children
| Reported by: | anonymous | Owned by: | cmlenz |
|---|---|---|---|
| Priority: | major | Milestone: | 0.5.2 |
| Component: | General | Version: | 0.5.1 |
| Keywords: | xpath | Cc: |
Description
[Sorry if my terminology is inaccurate, but I am no XML expert...]
Here is what I do:
from genshi.input import html
from genshi.filters import Transformer
html = HTML('<ul><li>item1<ul><li>subitem11</li></ul></li><li>item2<ul><li>subitem21</li></ul></li></ul>')
print html | Transformer('li[1]/ul').attr('attribute', 'value')
Then I do get what I expect (sub-ul of first top-level li selected):
<ul><li>item1<ul attribute="value"><li>subitem11</li></ul></li><li>item2<ul><li>subitem21</li></ul></li></ul>
But if:
print html | Transformer('li[2]/ul').attr('attribute', 'value')
I would expect that sub-ul of second top-level li be selected), but here is what I get:
<ul><li>item1<ul><li>subitem11</li></ul></li><li>item2<ul><li>subitem21</li></ul></li></ul>
In other words: nothing is selected.
Attachments
Note: See
TracTickets for help on using
tickets.
