javax.xml.transform.stax


1. Convert XML to HTML using STAX

import javax.xml.stream.*;
import javax.xml.transform.*;
import javax.xml.transform.sax.*;
import javax.xml.transform.stax.StAXResult;
import javax.xml.transform.stax.StAXSource;
import org.xml.sax.helpers.AttributesImpl;

public class XmlToHtml {

    public static void main(String[] args) throws Exception {
        XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(System.in);
        StAXSource source = new StAXSource(xmlReader);

        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.METHOD, "html");

        XMLStreamWriter htmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
        StAXResult result = new StAXResult(htmlWriter);

        transformer.transform(source, result);
    }
}

2. Transform XML to JSON using STAX

3. Parse XML using STAX and SAX

4. Create XML using STAX and SAX

5. Parse XML with STAX and XPath

6. Create XML with STAX and XSLT

7. Convert XML to PDF using STAX and FOP

8. Process XML Events using STAX

9. Create XML Namespaces using STAX

10. Validate XML using STAX

11. Parse XML Fragments using STAX

12. Create XML Fragments using STAX

13. Use STAX with DOM

14. Use STAX with SAX