当前位置 : 主页 > 编程语言 > c语言 >

vb.net – HTML Agility Pack,在HTML文件中创建新行

来源:互联网 收集:自由互联 发布时间:2021-06-24
Dim codice As StringDim doc As New HtmlDocumentDim coll As HtmlNodeCollectionDim node As HtmlNodeDim nuovo As HtmlNodecodice = "lia href=""#"" onclick=""ApriClass('" + D_Clas.SafeFileName + "')"" title=""""� " + T_ClasNome.Text + "/a/li"d
Dim codice As String
Dim doc As New HtmlDocument
Dim coll As HtmlNodeCollection
Dim node As HtmlNode
Dim nuovo As HtmlNode

codice = "<li><a href=""#"" onclick=""ApriClass('" + D_Clas.SafeFileName + "')"" title="""">� " + T_ClasNome.Text + "</a></li>"
doc.Load("classifica.html")
coll = doc.GetElementbyId("subnavi").SelectNodes("ul")
node = coll.Last
nuovo = HtmlNode.CreateNode(codice)
node.AppendChild(nuovo)
doc.Save("classifica.html")

这会在指定位置的“codice”中添加一行HTML,但我注意到每次写入我的HTML文件时它都不会转到新行,所以它会写:

**(1st item)**<li><a href="#" onclick="ApriClass('classificagiocatori3.htm')" title="">� 3 Class</a></li>**(2nd item)**<li><a href="#" onclick="ApriClass('classificagiocatori.htm')" title="">� classificagioca.0tori.htm</a></li>

如何在HTML文件中转到新行以获得更加舒适的视图?

在C#中你可以尝试这样的东西.

var newLineNode = HtmlNode.CreateNode("\r\n");
var nuovo = HtmlNode.CreateNode(codice);
node.AppendChild(newLineNode);
node.AppendChild(nuovo);
node.AppendChild(newLineNode);
网友评论