我正在尝试使用 HTML Agility 包从 html 字符串中获取 som 数据。
我试图从返回 innerhtml 中获取数据的行字符串 [] 如下所示:
<td class="street">Riksdagen</td>
<td class="number"> </td>
<td class="number"> </td>
<td class="postalcode">100 12</td>
<td class="locality">Stockholm</td>
<td class="region_code">018001</td>
<td class="county">Stockholm</td>
<td class="namnkommun">Stockholm</td>
如何将每个类分配给正确的 addressDataModel 属性?
var row = doc.DocumentNode.SelectNodes("//*[@id='thetable']/tr");
foreach (var rowItem in row)
{
var addressDataModel = new AddressDataModel
{
street = rowItem.FirstChild.InnerText,
zipCodeFrom = // Next item,
zipCodeTo = // Next item,
zipCode = // Next item,
locality = // Next item,
regionCode = // Next item,
state = // Next item,
county = // Next item
};
}