LoginSignup
5
4

More than 5 years have passed since last update.

Firefoxが勝手に不足しているタグを挿入することによる弊害

Posted at

問題の概要

table直下にtrがある場合FirefoxがDOM上でtbodyタグを補完します。
そのため、Firebug等を用いてXPathやCSSパスをコピペしようとする際に実際のパスと異なったものが取得されます。
Firebug等からコピペしたパスを使ってWebページのスクレイピングを行うコードを書くときなどは注意してください。

Firefoxで開く前のHTMLソース

table.html
<table>
 <tr>
  <th><br></th>
  <th>列-A</th>
  <th>列-B</th>
  <th>列-C</th>
 </tr>
 <tr>
  <td>行-1</td>
  <td>A1</td>
  <td>B1</td>
  <td rowspan=2>C1-C2</td>
 </tr>
 <tr>
  <td>行-2</td>
  <td>A2</td>
  <td>B2</td>
 </tr>
 <tr>
  <td>行-3</td>
  <td>A3</td>
  <td colspan=2>A3-B3</td>
 </tr>
</table>

Firebug上で取得したHTMLソース

table.html
<table>
 <tbody><tr>
  <th><br></th>
  <th>列-A</th>
  <th>列-B</th>
  <th>列-C</th>
 </tr>
 <tr>
  <td>行-1</td>
  <td>A1</td>
  <td>B1</td>
  <td rowspan="2">C1-C2</td>
 </tr>
 <tr>
  <td>行-2</td>
  <td>A2</td>
  <td>B2</td>
 </tr>
 <tr>
  <td>行-3</td>
  <td>A3</td>
  <td colspan="2">A3-B3</td>
 </tr>
</tbody></table>

tbodyタグが勝手に挿入されていることが分かります。

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4