[英]Name cannot begin with the '=' character hexadecimal value 0x3d when use xslt
I have some html. 我有一些HTML。 I try to clean it with library: http://sourceforge.net/projects/tidynet/
我尝试使用库进行清理: http : //sourceforge.net/projects/tidynet/
Here is my code: 这是我的代码:
//clean up html
Tidy tidy = new Tidy();
tidy.Options.DocType = DocType.Omit;
tidy.Options.DropFontTags = true;
tidy.Options.LogicalEmphasis = true;
tidy.Options.Xhtml = true;
tidy.Options.XmlOut = true;
tidy.Options.MakeClean = true;
tidy.Options.TidyMark = false;
tidy.Options.CharEncoding = CharEncoding.UTF8;
/* Declare the parameters that is needed */
TidyMessageCollection tmc = new TidyMessageCollection();
MemoryStream input = new MemoryStream();
MemoryStream output = new MemoryStream();
byte[] byteArray = Encoding.UTF8.GetBytes(report);
input.Write(byteArray, 0, byteArray.Length);
input.Position = 0;
tidy.Parse(input, output, tmc);
string cleanHtml = Encoding.UTF8.GetString(output.ToArray());
then I try to use xslt: 然后我尝试使用xslt:
try
{
StringBuilder res = new StringBuilder();
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(XmlReader.Create(new StringReader(stylesheet.Content)));
xslt.Transform(StringExtensions.ToXmlReader(cleanHtml), null, new StringWriter(res));
var resultReport = res.ToString();
}
catch (Exception e)
{
}
and I get an exeption: 我得到一个例外:
The '=' character, hexadecimal value 0x3D, cannot be included in a name 名称中不能包含“ =”字符(十六进制值0x3D)
Update How can I automaticaly clean name from '='? 更新如何自动从'='中清除名称?
HTML is not XML (unless it's XHTML). HTML不是XML(除非是XHTML)。 Trying to apply an XSLT to a generic HTML document is almost certainly going to give you issues.
几乎肯定会尝试将XSLT应用于通用HTML文档会给您带来问题。 You'll have to find a different way to do whatever transformation it is that you're looking for.
您将必须找到一种不同的方式来进行所需的转换。
If you want to process the HTML programmatically, then I would suggest the HTML Agility Pack . 如果您想以编程方式处理HTML,则建议使用HTML Agility Pack 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.