var div = element as Div;
if (div.GetAccessibilityProperties().GetRole() == "H1") title = true;
和额外的helper来从元素中获取内容,以填充TOC:
private static string GetContent(IElement element)
{
var builder = new StringBuilder();
if (element is Text) builder.Append(((Text)element).GetText());
if (element is IAbstractElement)
foreach (var child in (element as IAbstractElement).GetChildren())
builder.Append(GetContent(child));
return builder.ToString();
}
1条答案
按热度按时间5n0oy7gb1#
我做到了。将元素转换为div,然后通过Role获取标记名。
和额外的helper来从元素中获取内容,以填充TOC: