Use TxAX (Transformation API for XML) and XSLT (XSL Transformations) for this.
The process is:
- write an XSLT. It contains rules for input file tags and what to output in output file when those rules are matched. You need to know XPath syntax because that's what helps in handling tags without knowing their names. For example, the xpath expression "/Application//EmailAddress" will return all nodes under <Application> at any depth whose tag is <EmailAddress>, and "/Application//*" returns all descendant nodes regardless of tag name. These rules go into the XSLT.
- Use the
javax.xml.transform API to execute that XSLT on your input XML and produce output HTML. The XSLT takes in your XML input, uses the XPath expressions in that XSLT to match nodes in XML input, and outputs HTML.
Found a
tutorial here