zoukankan      html  css  js  c++  java
  • [Fatal Error] :3:13: Open quote is expected for attribute "{1}" associated with an element type "id".

    用DOM解析XML时出现了如下错误:

    [Fatal Error] :3:13: Open quote is expected for attribute "{1}" associated with an  element type  "id".
    org.xml.sax.SAXParseException: Open quote is expected for attribute "{1}" associated with an  element type  "id".
     at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:246)
     at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
     at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)
     at com.xml.DOMDemo.parseDomXML(DOMDemo.java:26)
     at com.xml.DOMDemo.main(DOMDemo.java:14)

    检查后发现我的xml文件是这样写的

    <?xml version="1.0" encoding="UTF-8"?>
    <message>
         <person id=1>
            <name>jerry</name>
            <age>18</age>
            <sex>男</sex>
        </person>
        <person id=2>
           <name>Aimi</name>
          <age>20</age>
          <sex>女</sex>
       </person>
    </message>

    错误就在于,xml元素的开始标签的属性必须用双引号括起来

    改为:

    <person id="1">

    <person id="2">

  • 相关阅读:
    matlab中fft与fftshift命令小结(转)
    matlab 添加多行注释
    matlab colormap,caxis,shading,hsv,pcolor, alpha 表示(转)
    在线latex公式编辑器
    matlab 对话框弹出
    步态识别 概要
    JavaScript函数
    MySQL多表查询总结
    VS2005打不开 卡在登入状态
    about project
  • 原文地址:https://www.cnblogs.com/chenxing818/p/4768007.html
Copyright © 2011-2022 走看看