How to store xml data from the sql server to the arraylist in java


I am retrieving data from the MySQL server, where one column name is having the datatype as XML. I need the data inside XML attribute for some comparison. I want to store data type and values of the XML attribute in one List<ArrayList<String>> because another side of my data to be compared in ArrayList. Suggest me using the ResultSet to access from the database, How I can store in java List<ArrayList<String>>?

Thanks in advance.

Resultset has getSQLXML() method which can be used for fetching XML from the xml datatype column.

Use ResultSetMetaData to confirm the datatype returned by xml datatype column.

Use getString() method from SQLXML interface to get XML data in the form of string and then use JAXB for converting XML to POJO.

Alternatively, you can get the binary stream from SQLXML and use parsers such as SAX, DOM or StAX parser.