html在文件中插入一个文件,c#如何在html文件中,插入一段html标签代码?

Hi,

根据我的了解,Html里面的节点就是固定的几种,添加Html你可以使用这个方法来添加。

HtmlNodediv=doc.CreateElement("div");myNode.Append(div);

如果你是想对xml针对操作,方法有两种。

XmlNode.InsertAfter Method 和 XmlNode.AppendChild Method。

下面是我测试的代码,希望对你有帮助。

XmlDocument doc = new XmlDocument();

doc.LoadXml("" +

"

Pride And Prejudice" +

"");

XmlNode root = doc.DocumentElement;

//Create a new node.

XmlElement elem = doc.CreateElement("p");

elem.InnerText = "19.95";

//Add the node to the document.

root.InsertAfter(elem, root.FirstChild);

Console.WriteLine("Display the modified XML...");

doc.Save(Console.Out);

Best Regards,

Hart

Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints

to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值