我在 HTML 文件的脚本标记中嵌入了一些(实际上是很多)XML。我抓住这些数据来处理
var xmlString = document.getElementById('xmldata').innerHTML;
以下是数据示例:
<script id="xmldata" type="text/xml">
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Nick</Author>
当我使用时,$.parseXML(xmlString)
我在 Chrome 中得到以下信息:
Uncaught Error: Invalid XML:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:offic...<omitted>...
奇怪的是,它在 Internet Explorer 11 中运行良好。我曾经$.isXMLDoc(xmlString)
测试过它是否已经是 XML Doc,但它返回 False。那么这在 Chrome 中不起作用是什么?