I have the following XML:
<?xml version="1.0" encoding="utf-16"?>
<ROOT>
<fieldset>
<field Id="c0" Name="_ID_VERSION" DataType="int"/>
<field Id="c1" Name="_TYPE" DataType="string"/>
<field Id="c2" Name="_PRODUCT" DataType="string"/>
<field Id="c3" Name="_VERSION" DataType="string"/>
<field Id="c4" Name="_REVISION" DataType="int"/>
<field Id="c5" Name="_STATE" DataType="string"/>
<field Id="c6" Name="_DOCUMENT" DataType="int"/>
<field Id="c7" Name="_HAS_LINK" DataType="int"/>
<field Id="c8" Name="_LOCKED" DataType="int"/>
<field Id="c9" Name="_ACCESSLEVEL" DataType="int"/>
<field Id="c10" Name="_LABEL" DataType="int"/>
<field Id="c11" Name="_LABEL_NAME" DataType="string"/>
</fieldset>
<rowset>
<row c0="2932" c1="" c2="{3FDAC10D-5361-4C32-B79E-D391DCB3AE98}" c3="" c4="0" c5="" c6="0" c7="1" c8="0" c9="3" c10="-1" c11=""/>
<row c0="3146" c1="0" c2="MyProject" c3="" c4="0" c5="" c6="0" c7="1" c8="1" c9="3" c10="-1" c11=""/>
<row c0="3147" c1="" c2="tes" c3="" c4="0" c5="" c6="0" c7="1" c8="0" c9="3" c10="-1" c11=""/>
<row c0="2933" c1="" c2="" c3="" c4="0" c5="" c6="0" c7="1" c8="0" c9="3" c10="-1" c11=""/>
<row c0="3048" c1="" c2="" c3="" c4="0" c5="" c6="0" c7="1" c8="0" c9="3" c10="-1" c11=""/>
</rowset>
</ROOT>
How to I can map this text to POJO in java? I have tried parsing it with the following code:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
Document document = null;
try {
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource(new StringReader(incomming));
document = db.parse(is);
} catch (ParserConfigurationException | SAXException | IOException e) {
e.printStackTrace();
}
return document;
But I want to do it automatically.
<row c0="3147" c1="0?:0 :>=B@035=B>2" c2="tes" c3="" c4="0" c5="!CI5AB2C5B" c6="0" c7="1" c8="0" c9="3" c10="-1" c11=""/>does not look like valid XML.idVersion,type,productetc. orfieldset,rowsetetc?