Imports DTG.Html Imports DTG.Css Module Module1 Dim indent As String = "" Sub Main() Dim htmltext As String = "
Bold text
before
Italic text
" ' Build DOM of the html Dim html As HtmlDoc = HtmlDoc.ParseHTML(htmltext) ' The function changes text style from italic to underline ScanHtmlTree(html.Nodes) ' Show the tree of the html ViewHtmlDOM(html.Nodes) Console.ReadLine() End Sub Sub ScanHtmlTree(ByVal nodes As HtmlNodeCollection) For Each node As HtmlNode In nodes If node.IsElement Then Dim tag As HtmlTag = CType(node, HtmlTag) If tag.Attributes.IndexOf("style") >= 0 Then tag.Attributes("style").Value = "text-decoration:underline;" End If ScanHtmlTree(tag.Nodes) End If Next End Sub Sub ViewHtmlDOM(ByVal nodes As HtmlNodeCollection) For Each node As HtmlNode In nodes If node.IsText Then Dim Text As HtmlText = CType(node, HtmlText) Console.WriteLine(indent + Text.ToString()) Else Dim tag As HtmlTag = CType(node, HtmlTag) Console.WriteLine(indent + tag.ToString()) indent += " " ViewHtmlDOM(tag.Nodes) indent = indent.Substring(0, indent.Length - 2) Console.WriteLine(indent + "" + tag.Name + ">") End If Next End Sub End Module