XPATH:查找包含多个文本的行

时间:2017-07-31 10:56:25

标签: xpath

我不确定为什么但是下面的查询

.//*[@id='training_modules_list_table']/thead/tr[th[text()='ID']and th[text()='NAME']and th[text()='STATUS']and th[text()='VERSION']and th[text()='PACKAGE']and th[text()='REFERENCE']]

在下面的html中找不到任何内容。

<table class="table  sortable stripe tablesaw-stack" data-tablesaw-mode="stack" id="training_modules_list_table">
            <thead>
            <tr>
              <th data-sort="int"><a href="/test1/admin/training?direction=asc&amp;sort=id">ID</a></th>
              <th data-sort="string"><a href="/test1/admin/training?direction=asc&amp;sort=name">Name</a></th>
              <th data-sort="string"><a href="/test1/admin/training?direction=asc&amp;sort=status">Status</a></th>
              <th data-sort="string"><a href="/test1/admin/training?direction=asc&amp;sort=version">Version</a></th>
              <th data-sort="string"><a href="/test1/admin/training?direction=asc&amp;sort=package">Package</a></th>
              <th>Assigned Study</th>
              <th data-sort="string"><a href="/test1/admin/training?direction=asc&amp;sort=reference">Reference</a></th>
              <th data-sort="string"></th>
            </tr>
            </thead>

            <tbody>
            <tr>

1 个答案:

答案 0 :(得分:0)

虽然你的问题提供的信息少了实际上你想要实现的内容但是在看到你的xpath之后看起来你正试图写一个xpath,它会返回你所有的标签元素。

尝试以下xpath: -

//table[@id='training_modules_list_table']//tr/th/a

它将返回a标记

中的所有元素

希望它会对你有所帮助:)。

相关问题