我正在使用HTMLAgilityPack,我正在使用标准操作程序来加载文档并选择一个节点。但是当我去查看节点时,所有的aspx控件都是小写的。有没有办法让它成为正确的例如当我查看<asp:RequiredFieldValidator
时,它返回为<asp:requiredfieldvalidator
。这不会起作用,因为我正在大量更新我的控件。
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.Load(@"C:\my.ascx");
HtmlNodeCollection node_collection = doc.DocumentNode.SelectNodes("//div");
foreach (HtmlNode node in node_collection)
{
templateString = node.InnerHtml; //lower case happens here.....
}
任何人
答案 0 :(得分:4)
您需要的是在OptionOutputOriginalCase
Load
var doc = new HtmlAgilityPack.HtmlDocument();
doc.OptionOutputOriginalCase = true;
doc.LoadHtml("<html><asp:RequiredFieldValidator></asp:RequiredFieldValidator></html>");
var html = doc.DocumentNode.InnerHtml;
答案 1 :(得分:0)
尝试将代码更改为
function fauxNew (constructor, args) {
// allocate a new object and set the prototype
var newObject = Object.create(constructor.prototype)
// call the constructor with "this" bound to the new object
var retVal = constructor.apply(newObject, args || [])
// if the constructor returned an object, return it;
// otherwise return the new object
var constructorReturnedAnObject =
!!retVal && ["object", "function"].indexOf(typeof retVal) !== -1
return constructorReturnedAnObject? retVal : newObject
}