The Apache Software Foundation > Apache XMLBeans

XmlTree Sample


Author: Steve Traut

Available: 2005-07-08

Versions: xmlbeans-1.0.3, xmlbeans-v2

This sample illustrates how you can use the XMLBeans API to create a Java tree view of an XML document. The JTree implementation in the sample supports binding to any XML document. By accessing bound XML using an XmlCursor instance and XPath rather than through accessors provided by compiling schema, the data model behind this tree can support XML without regard to schema. The XmlEntry contains the simple code that is XMLBeans-aware. The XmlModel class, with which the tree implementation interacts directly, in turn knows nothing of XMLBeans or the underlying XML, instead reaching the data through XmlEntry instances.