いつもお世話になります。
C#, Windows7/8.1/10, VisualStudio 2010/2013 Expressで開発しています。
下記のようなhtmlから
利用日
利用店名・商品名
利用金額
を抜き出して配列に入れたいです。
html
<table class="tableStyle01 textStyle01" border="1" cellspacing="0">
<thead>
<tr>
<th scope="col" class="w13">利用日</th>
<th scope="col" class="w40">利用店名・商品名</th>
<th scope="col" class="w10">支払方法<br />※1</th>
<th scope="col" class="w10">利用金額<br />※2</th>
<th scope="col">初回請求月</th>
<th scope="col" class="w17">支払い変更可能</th>
</tr>
</thead>
<tfoot>
<tr>
<td class="subtotal" colspan="3">回数指定払い合計金額</td>
<td>147,727</td>
<td> </td>
<td> </td>
</tr>
</tfoot>
<tbody>
<tr>
<td align="center">2015/10/26</td>
<td>EC-JOYプレミアム楽天市場 ラクテンイチバ750068
</td>
<td align="center">1回
</td>
<td align="right">142
</td>
<td align="center">2015/12
</td>
<td align="center"> </td>
</tr>
<tr>
<td align="center">2015/10/26</td>
<td>イトーヨーカドー
</td>
<td align="center">1回
</td>
<td align="right">795
</td>
<td align="center">2015/12
</td>
<td align="center"> </td>
</tr>
C# code
WebBrowserのDocumentCompletedで、
HtmlElementCollection tables =
webBrowser.Document.GetElementsByTagName("table");
foreach (HtmlElement table in tables) {
string tabletext = table.GetAttribute("class");
if (tabletext.Contains("tbaleStyle01")){
MessageBox.Show(table.OuterText);
}
}
まずtableというtagで抜き出して、classのattributeを取ろうとしていますが、とれずにtabletextが空になります。
なぜGetAttribute("class")は機能しないのでしょう。
GetAttribute("href")とかは動くのですが。
こういう場合はどうすればよいかご示唆ください。
回答1件
あなたの回答
tips
プレビュー