P粉1869047312023-08-22 13:13:03
This error means that your XML has tags after the root element. To comply with well-formed requirements, XML must have only one root element, and no other tags after the single root element .
An example of a root element (correct)
<r> <a/> <b/> <c/> </r>
The most common causes of this error are:
Contains extra closing tags (error):
<r> <a/> <b/> <c/> </r> </r> <!-- 不应该出现在这里 -->
Intentionally having multiple root elements (error):
<a/> <b/> <!-- 第二个根元素不应该出现在这里 --> <c/> <!-- 第三个根元素不应该出现在这里 -->
Inadvertently having multiple root elements (error):
<r/> <!-- 不应该是自闭合的 --> <a/> <b/> <c/> </r>
The parsed XML is different than you think (wrong):
Log the XML immediately before feeding it to the parser to ensure that the XML the parser sees is the same XML you think it is. Common mistakes here include:
In your specific case, your XML appears to have multiple root elements because the xsl:stylesheet
element is closed prematurely (case #3 above).
Will
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
change to
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
to address your immediate question and add a closing tag
</xsl:stylesheet>
If it doesn't exist yet in your actual document.