我使用这段代码来使用XSLT模板将XML转换为HTML:
string uri = Server.MapPath("~/template.xslt");
XslCompiledTransform xsl = new XslCompiledTransform();
xsl.Load(uri);
XDocument xml = new XDocument(new XElement("Root"));
StringBuilder builder = new StringBuilder();
XmlReader reader = xml.CreateReader();
XmlWriter writer = XmlWriter.Create(builder, xsl.OutputSettings);
xsl.Transform(reader, writer);
writer.Close();
我的模板长这样:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes" />
<xsl:template match="Root">
<html>
<head>...
输出结果是正确的,但包含META标签。如何禁用转换,以便不生成META标签?