Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void WriteHtml(HtmlNode rootNode, int indent)
- {
- html.Append(new string(' ', indent * 4) + $"<{rootNode.Name}");
- foreach (var attr in rootNode.Attributes)
- {
- html.Append($" {attr.Name}=\"{attr.Value}\"");
- }
- html.Append(">");
- if (rootNode.ChildNodes.Count > 0)
- {
- html.AppendLine();
- foreach (var node in rootNode.ChildNodes)
- {
- WriteHtml(node, indent + 1);
- }
- html.AppendLine(new string(' ', indent * 4) + $"</{rootNode.Name}>");
- }
- else
- {
- html.AppendLine($"</{rootNode.Name}>");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement