【发布时间】:2013-07-02 08:06:16
【问题描述】:
我有以下 xml 片段。
<root>
<site type="main">
<link>http://stackexchange.com</link>
</site>
<site type="qa">
<link>http://stackoverflow.com</link>
</site>
<site type="qa">
<link>http://superuser.com</link>
</site>
<site type="">
<link>http://data.stackexchange.com</link>
</site>
</root>
我想选择“qa”类型的第一个站点的链接。我认为//site[@type="qa"][1] 应该这样做。但是 id 不起作用。
【问题讨论】:
标签: python xml xpath scrapy xpath-1.0