http://Bj83.de

XML Handle mit JDom in Java

jar: http://www.jdom.org/

import java.io.File;
import java.io.IOException;
import java.util.*;

import org.jdom2.*;
import org.jdom2.input.SAXBuilder;

public class xml_test {
	public String sFile;
	private SAXBuilder builder = new SAXBuilder();
	private Document dXml;

	public xml_test() throws JDOMException, IOException {
		File file = new File(sFile);
		dXml = builder.build(file);
		Element elem = dXml.getRootElement();
		List<Element> eXMLData = elem.getChildren("XMLDATA");
		for(int i = 0; i < eXMLData.size(); i++){
			Element em = eXMLData.get(i);
			String sNodeValue = em.getChildText("NODENAME");
			System.out.println(sNodeValue);
		}
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: