I have the following xml:
...
<chapter>
<start_time>00:01:04</start_time>
</chapter>
<chapter>
<start_time>00:01:05</start_time>
</chapter>
...
Currently, to get the start_times I am doing:
start_times = node.xpath("//t:start_time/text()",
namespaces={'t':'http://example.com/namespace'})
However, I am also getting start_times from non-chapter elements:
[00:00:01, 00:00:02, 00:01:04, 00:01:05]
In addition, for some reason suing //t:chapter/start_time returns an empty result.
How would I get only those start_times that have a parent element of chapter?
Make your selector more specific like this: