我想加载一个XML文件,但我得到以下错误,我使用加载('');或loadXML();我猜这个错误不在负载之中,但我想不出是什么情况。我在这里错过了什么?使用DOM加载和loadXML的错误
的XSLT
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
version="1.0">
<xsl:template match="files">
<xsl:variable name="docs">
<docs>
<xsl:for-each select="file">
<xsl:copy-of select="document(.)"/>
</xsl:for-each>
</docs>
</xsl:variable>
<xsl:apply-templates select="msxsl:node-set($docs)"/>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
<xsl:template match="item">
<product>
<xsl:apply-templates select="node() | @*" />
</product>
</xsl:template>
</xsl:stylesheet>
我觉得你在这里混了两两件事:你的国家为'load'的错误显然是一个'loadXml'错误,这是可以理解为'loadXml'预计XML作为一个字符串,如果你在这里放置一个文件路径,你会得到这个错误。第二个看起来像一切工作(加载),但你的xslt文件中有错误。 (请发布xslt文件) – Yoshi
@Yoshi @Gordon我用XSLT更新了这个问题。 – EnexoOnoma
它可能只是我,但不应该'$ xslt = new DomDocument;''xslt = new DomDocument();'? – Nanne