SharpDOM可以让你直接使用C#的语法来编写网页,举个例子:
下面是一段HTML代码:
<html><head><title>Titleofthepage</title><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"><linkhref="css/style.css"rel="stylesheet"type="text/css"><scripthref="/JavaScripts/jquery-1.4.2.min.js"type="text/javascript"></head><body><div><h1>TestFormtoTest</h1><formid="Form1"type="post"><label>Parameter</label>=<inputtype="text">Entervalue</input><inputtype="submit"text="Submit!"/></form><div><p>Textualdescriptionofthefooter</p><ahref="https://google.com"><span>Youcanfindushere</span></a><div>Anothernestedcontainer</div></div></div></body></html>使用SharpDOM来编写的话,就变成了
html[head[title["Titleofthepage"],meta.attr(http-equiv:"contenttype",content:"html",charset:"utf-8"),link.attr(href:"css/style.css",rel:"stylesheet",type:"css"),script.attr(href:"/JavaScripts/jquery-1.4.2.min.js",type:"javascript")],body[div[h1["TestFormtoTest"],form.attr(id:"Form1",type:"post")[label["Parameter"],"=",input.attr(type:"text",value:"Entervalue"),br,input.attr(type:"submit",value:"Submit!")],div[p["Textualdescriptionofthefooter"],a.attr(href:"https://google.com")[span["Youcanfindushere"]]],div["Anothernestedcontainer"]]]]
评论