XMLBeans/Beispiel: Unterschied zwischen den Versionen
Aus Joachim Schuster Wiki
Zeile 1: | Zeile 1: | ||
− | + | == Projekteinstellungen == | |
− | + | == Beispielcode == | |
− | + | <pre> | |
− | + | import java.io.File; | |
− | + | import java.io.IOException; | |
− | + | import org.apache.xmlbeans.*; | |
− | + | import noNamespace.*; | |
− | + | import noNamespace.ItemDocument.Item; | |
− | + | ||
− | + | ||
− | + | ||
− | + | public class firstxml { | |
− | + | public static void main(String[] args) { | |
− | + | File xmlFile = new File("./firstxmlbean.xml"); | |
+ | ItemsDocument iDoc = null; | ||
+ | try { | ||
+ | iDoc = ItemsDocument.Factory.parse(xmlFile); | ||
+ | } catch (XmlException e) { | ||
+ | e.printStackTrace(); | ||
+ | } catch (IOException e) { | ||
+ | e.printStackTrace(); | ||
+ | } | ||
+ | Item[] items = (iDoc.getItems()).getItemArray(); | ||
+ | for (int i = 0; i < items.length; i++) | ||
+ | { | ||
+ | System.out.println(items[i]); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | </pre> |
Version vom 29. Juli 2007, 14:29 Uhr
Projekteinstellungen
Beispielcode
import java.io.File; import java.io.IOException; import org.apache.xmlbeans.*; import noNamespace.*; import noNamespace.ItemDocument.Item; public class firstxml { public static void main(String[] args) { File xmlFile = new File("./firstxmlbean.xml"); ItemsDocument iDoc = null; try { iDoc = ItemsDocument.Factory.parse(xmlFile); } catch (XmlException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Item[] items = (iDoc.getItems()).getItemArray(); for (int i = 0; i < items.length; i++) { System.out.println(items[i]); } } }