It drives me crazy. I used this bit of code for many different projects, but this is the first time that he has given me this type of error. This is the whole XML file:
<layers> <layer name="Layer 1" h="400" w="272" z="0" y="98" x="268"/> <layer name="Layer 0" h="355" w="600" z="0" y="287" x="631"/> </layers>
Here is the online bit of code in my homebrew Xml class that uses DocumentBuilderFactory to parse the Xml loaded into it:
public static Xml parse(String xmlString) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = null; //System.out.print(xmlString); try { doc = dbf.newDocumentBuilder().parse( new InputSource(new StringReader(xmlString))); // Get root element... Node rootNode = (Element) doc.getDocumentElement(); return getXmlFromNode(rootNode); } catch (ParserConfigurationException e) { System.out.println("ParserConfigurationException in Xml.parse"); e.printStackTrace(); } catch (SAXException e) { System.out.println("SAXException in Xml.parse "); e.printStackTrace(); } catch (IOException e) { System.out.println("IOException in Xml.parse"); e.printStackTrace(); } return null; }
The context I use is: a school project to create an application for manipulating images like Photoshop. The file is saved with layers as .png and this xml file for position, etc. Layers in a .zip file. I don't know if zipping adds some mysterious extra characters or not.
I appreciate your feedback.
source share