Transforming XML with SAX Filters
This Example shows you the way to Transform XML with SAXFilters. JAXP (Java API for XML Processing) is an interface which provides parsing of xml documents. Here the Document BuilderFactory is used to create new DOM parsers.There are some of the methods used in code given below for Transforming:-
FileReader fileReader = new FileReader("Document2.xml"):-Creates a new FileReader by which the File is readed from.
SAXSource source = new SAXSource(filter, inputSource):-Creates a SAXSource object which acts as an holder for SAX-style Source.
FileWriter fw = new FileWriter("out.xml"):-Creates a new FileWriter object given a File ObjectTransformerFactory factory = TransformerFactory.newInstance():-TransformerFactory is a class that is used to create Transformer objects. A TransformerFactory instance can be used to create Transformer and Templates objects.
Xml code for the program generated is:-
|
XMLwithSAX.java
|
Output of the program:-
|
|
Recommend the tutorial |
Ask Questions? Discuss: XML,XML Tutorials,Online XML Tutorial,XML Help Tutorials
Post your Comment