Java XML transformer for processing XML

With the java XML transformer you can transform the XML documents into other forms. The most common imports that are needed to work with the transformer class in your java program include,

import java.io.*;
. . .
. . .
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;

To create a transformer object you have to use the TransformerFactory's newTransformer() method. With this method you can create an instance of the transformer class.

TransformerFactory transfact = TransformerFactory.newInstance();
Transformer trans = transformerFactory.newTransformer();
. . .
. . .
trans.transform(src, res);

The above code snippet will do the transformation needed in your java program. The transform method of the transformer object takes two parameters called the source and the result. In the above code snippet the 'src' is a DOMSource object and the 'res' is a StreamResult object. These two can be created using the code as given below,

DOMSource src = new DOMSource(docObj);
StreamResult res = new StreamResult(fileOutStr);

In the above code the 'docObj' is the document object and the 'fileOutStr' is the FileOutputStream.

Lots of examples of using the transformer object is available in the internet.



.

SetApp - 100 Apps for everything you ever wanted to do on Mac

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________






 

 

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!

Visit XML Training Material Guide Homepage

 

 

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

Copyright - © 2004 - 2019 - All Rights Reserved.