Java-XML

Extensible Markup Language (XML) is a standard from the World Wide Web Consortium for the formal syntax of markup languages that you can display structured data in the form of plain text. This representation is both readable and machine readable for humans. The XML format is used to store data and to transmit data over the Internet to send (as in AJAX).XML is a simplified form of Standard Generalized Markup Language (SGML), a standard for the complex structure of documents to capture.Languages called XML elements and attributes for data structuring. The XML specification defines the syntax elements, attributes and other structures in XML files can occur. The XML specification places no names for these elements and attributes, precisely because the choice depends on the purpose of the XML file.

Java has two built-in XML parsers. e.g: DOM and SAX, both have their pros and cons. Look at the examples, and don't hesitate to leave a comment with your thoughts.



XML & Properties


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

  Convert properties file into XML file
  Convert XML file into properties fileHow 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.

  Read a XML file with SAXHow 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.

  Create XML file with DOMHow to create a XML file with DOM
  Read a XML file with DOMHow to read a XML file with DOM
  Delete XML nodes with DOMHow to delete a XML node with DOM


JAX-B Examples


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

  JAX-B MarshalHow to marshal a XML file using JAX-B
  JAX-B UnmarshalHow to unmarshal with JAX-B


XPath tutorials


Finding XML elements

  XPath tutorialHow to search through xml nodes with XPath


An older of SGML markup language derived HyperText Markup Language (HTML). HTML is an SGML-like breakthrough in design text provided, but data on an HTML page are for computers are not recognized as such: for example, in HTML you can mark titles and paragraphs (text structure), but one can not establish that a certain person given a name, a phone number or a date (meaning or semantic structure). With XML markup languages, however, can develop which this is possible.