简体   繁体   English

使用xslt时,名称不能以'='字符十六进制值0x3d开头

[英]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.

相关问题 '=' 字符,十六进制值 0x3D,不能包含在名称中 - The '=' character, hexadecimal value 0x3D, cannot be included in a name 名称不能以&#39;&#39;字符开头,十六进制值0x20 - Name cannot begin with the ' ' character, hexadecimal value 0x20 DataContractSerializer-名称不能以“。”开头 字符,十六进制值0x2E - DataContractSerializer - Name cannot begin with the '.' character, hexadecimal value 0x2E 名称不能以 '&lt;' 字符十六进制值 0x3c 开头 - Name cannot begin with the '<' character hexadecimal value 0x3c XDocument错误名称不能以&#39;&lt;&#39;字符开头,十六进制值0x3C - XDocument Error Name cannot begin with the '<' character, hexadecimal value 0x3C xml.Linq:“名称不能以 &#39;?&#39; 开头字符,十六进制值 0x3F&quot; - xml.Linq: "Name cannot begin with the '?' character, hexadecimal value 0x3F" 名称不能以“1”字符开头,十六进制值0x31。 第2行,第2位 - Name cannot begin with the '1' character, hexadecimal value 0x31. Line 2, position 2 将Firebase广告添加到Xamarin.Forms会导致:名称不能以&#39;$&#39;字符开头,十六进制值为0x24 - Adding Firebase Ads to Xamarin.Forms causes: Name cannot begin with the '$' character, hexadecimal value 0x24 名称不能以“1”字符开头,十六进制值0x31。 从xml文件中读取时 - Name cannot begin with the '1' character, hexadecimal value 0x31. while reading from an xml file WCF服务参考 - 获取“XmlException:名称不能以&#39;&lt;&#39;字符开头,十六进制值0x3C”在客户端 - WCF Service Reference - Getting “XmlException: Name cannot begin with the '<' character, hexadecimal value 0x3C” on Client Side
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM