XML Parser for importing data

Dear Supportteam

Is there already a sample how to parse/import an xml-file ?
There is already io.jmix.flowui.sys.ViewXmlParser

Regards
Felix

Hi,

Could you describe your task in more detail?

Regard,
Gleb

Hi Gleb

Import an xml-file (Camt) with bankdata to add payments in a table of a Jmix application.

Regards
Felix

The workflow could be the following:

  1. Upload a file using the upload component
  2. Get file content as String e.g. by converting InputStream to string: IOUtils.toString(stream, StandardCharsets.UTF_8) (see io.jmix.flowui.sys.ViewXmlLoader#loadTemplate)
  3. Convert String content to org.dom4j.Document using io.jmix.core.common.util.Dom4j#readDocument(java.lang.String)
  4. Handle org.dom4j.Elements according to the document structure by reading nested elements and their attributes. Use any of the component loaders as an example and io.jmix.flowui.xml.layout.support.LoaderSupport to facilitate parsing data from XML.