[Java] XML-Datei laden

import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * Datei im XML-Format (*.xml) laden
 * @param filename Dateiname
 * @return true, wenn Laden erfolgreich
 * @throws IOException 
 */
public boolean LoadXML(String filename) throws IOException
{
    boolean bRetVal = false;

    try
    {
        File f = new File(filename);
        
        if (f.isFile() && f.canRead())
        {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
            DocumentBuilder builder = factory.newDocumentBuilder(); 
            Document doc = builder.parse(f);
            Node root = doc.getDocumentElement();
            root.normalize();
            
            if (root != null)
            {
                if (root.hasChildNodes())
                {
                    // Liste mit allen Elementen mit dem Bezeichner "item"
                    NodeList items = doc.getElementsByTagName("item");
                    
                    for (int i = 0; i < items.getLength(); i++)
                    {
                        Node item = items.item(i);
                        
                        // nodevalue, e.g. "0.5" or "Paul"
                        String nv = item.getNodeValue();
                        // nodename, e.g. <item>
                        String nn = item.getNodeName();
                        
                        // childs
                        NodeList childs = item.getChildNodes();
                        // attributes
                        NamedNodeMap attr = item.getAttributes();
                        
                        ...
                    }
                }
            }
            
            bRetVal = true;
        }
    }
    catch (Exception e)
    {
        bRetVal = false;
    }
    finally
    {
    }
    
    return bRetVal;
}