假设我有一个包含 tr 和 th 列表的表,我需要知道迭代中的当前标签是 th 还是 tr,我目前做了什么:
foreach (var tr in rows)
{
if(tr.InnerHtml.StartsWith("<th"))
我正在寻找一种更优雅的方式..
最佳答案
您可以使用 Name
property :
foreach (HtmlNode node in rows)
{
if(node.Name == "tr")
{
// ....
}
}
关于c# - 检查标签的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49192187/