Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using xerces could be more understandable:</p> <pre><code>public static void loadImetniks(String filePath) { File xmlFile; SAXBuilder builder; Element root, child; Imetnik imet;//another class that you have to create to help you for parsing Document doc; try { xmlFile = new File(filePath); builder = new SAXBuilder(); // parameters control validation, etc doc = builder.build(xmlFile); root = doc.getRootElement(); // Tr could be the root but I am not sure if you will have more Tr nodes in the same file?? tr.setRn(root.getAttributeValue(Constants.RN));//define the constants string in another file tr.setVr(root.getAttributeValue(Constants.VR)); tr.setSspre(root.getAttributeValue(Constants.SSPRE)); tr.setReg(root.getAttributeValue(Constants.REG)); tr.setIban(root.getAttributeValue(Constants.IBAN)); .... //repeat for every attribute .... List children = root.getChildren(); // depends of how many Imetnik you will have for (Iterator iter = children.iterator(); iter.hasNext();) { child = (Element) iter.next(); imet = new Imetnik(); imet.loadXML(child); // you have to define the loadXML function in your object Imetnik which should extract the attributes and internal nodes //imets.add(contest); // just use in the case that you will have to extract more than one Imetnik node } } catch (Exception e) { log.error("Error al hacer el parsing del contests.xml!"); log.error(e.getMessage()); } } </code></pre> <p>For instance, your Imetnik class should contain:</p> <pre><code> public void loadXML(Element root) { Element child; //Naslov naslov; // for Naslov because it could be an object itself davcna = root.getAttributeValue(Constants.DAVCNA); //define the string constant matSub = root.getAttributeValue(Constants.MATSUB); //define the string constant drz = Integer.parseInt(root.getAttributeValue(Constants.DRZ)); //define the string constant List children = root.getChildren(); // your root is Imetnik now for (Iterator iter = children.iterator(); iter.hasNext();) { ..... ....... } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload