MCPcopy Create free account
hub / github.com/antchfx/xpath / createHtmlExample

Function createHtmlExample

xpath_test.go:840–931  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

838}
839
840func createHtmlExample() *TNode {
841 /*
842 <html lang="en">
843 <head>
844 <title>My page</title>
845 <meta name="language" content="en" />
846 </head>
847 <body>
848 <h2>Welcome to my page</h2>
849 <ul>
850 <li>
851 <a href="/">Home</a>
852 </li>
853 <li>
854 <a href="/about">About</a>
855 </li>
856 <li>
857 <a href="/account">Login</a>
858 </li>
859 <li></li>
860 </ul>
861 <p>This is the first paragraph.</p>
862 <!-- this is the end -->
863 </body>
864 </html>
865 */
866 lines := 0
867 doc := createNode("", RootNode)
868 lines++
869 xhtml := doc.createChildNode("html", ElementNode)
870 xhtml.lines = lines
871 xhtml.addAttribute("lang", "en")
872 lines++
873 // head container
874 head := xhtml.createChildNode("head", ElementNode)
875 head.lines = lines
876 lines++
877 title := head.createChildNode("title", ElementNode)
878 title.lines = lines
879 title.createChildNode("My page", TextNode)
880 lines++
881 meta := head.createChildNode("meta", ElementNode)
882 meta.lines = lines
883 meta.addAttribute("name", "language")
884 meta.addAttribute("content", "en")
885 // skip the head
886 lines++
887 lines++
888 body := xhtml.createChildNode("body", ElementNode)
889 body.lines = lines
890 lines++
891 h2 := body.createChildNode("h2", ElementNode)
892 h2.lines = lines
893 h2.createChildNode("Welcome to my page", TextNode)
894 lines++
895 links := []struct {
896 text string
897 href string

Callers 1

xpath_test.goFile · 0.85

Calls 3

createNodeFunction · 0.85
createChildNodeMethod · 0.80
addAttributeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…