The following error occurred while parsing XML with DOM:
[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 Typ E "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)
After the check, I found my XML file was written like this.
<?xml version= "1.0" encoding= "UTF-8"?>
<message>
<person id=1>
<name>jerry</name>
<age>18</age>
<sex> Men </sex>
</person>
<person id=2>
<name>Aimi</name>
<age>20</age>
<sex> Women </sex>
</person>
</message>
The error is that the attributes of the start tag of the XML element must be enclosed in double quotation marks.
Switch
<person id= "1" >
<person id= "2" >
[Fatal Error]: 3:13:open quote is expected for attribute ' {1} ' associated with an element type ' ID '.