Java-XML

XML (Extensible Markup Language) is a structured language, which means that an XML file can describe exactly how data can be organized or arranged. Java has couple of features built in for working with XML files. First we have DOM XML Parser witch is the slowest of them all, but the easiest. Next we have SAX XML Parser whitch is much more memory efficient, but it's a bit harder. For marshalling/unmarshalling your java Objects there's JAX-B. Really nice API! You should take a look at this. For those who are interested I've also added a simple example of how to find elements in XML with XPATH. Happy learing XML. br/br/ strongPro's about XML/strong ul liXML is structured/li liXML can be validated/li liLanguage independent/li liXML is strongly typed/li liGlobal standard/li /ul strongCon's about XML/strong ul liSlower than a href="http://camelcode.org/overview/Java-JSON-tutorials.htm"JSON/a/li liMore difficult hant a href="http://camelcode.org/overview/Java-JSON-tutorials.htm"JSON/a/li /ul




XML & Properties


The java.util.Properties class has built-in functionality to convert properties file into XML file or vice versse.

arrow-right   Convert properties file into XML file
     

arrow-right   Convert XML file into properties file
     How to convert a XML file into properties


SAX XML Parser


SAX parser works differently then DOM parser, it does not load any XML document into memory, instead the SAX parser uses a callback function. As a result that this gives you a better performance.

arrow-right   Read a XML file with SAX
     How to read a XML file with SAX Parser


DOM XML Parser


The DOM parser is the easiest to use Java Parser. After loading the XML Document into memory, it is able to parse the document. But you have to keep in mind that when you load the entire XML Document in to memory there is a performance hit.

arrow-right   Create XML file with DOM
     How to create a XML file with DOM

arrow-right   Read a XML file with DOM
     How to read a XML file with DOM

arrow-right   Delete XML nodes with DOM
     How to delete a XML node with DOM


JAX-B Examples


JAXB, using annotation to convert Java object to / from XML file.

arrow-right   JAX-B Marshal
     How to marshal a XML file using JAX-B

arrow-right   JAX-B Unmarshal
     How to unmarshal with JAX-B


XPath tutorials


Finding XML elements

arrow-right   XPath tutorial
     How to search through xml nodes with XPath