Constructing DOM using StAX Writers

I recently added support for createXMLStreamWriter(DOMResult result) method in SJSXP. It is of great use where implementations spit out XML documents to a StreamWriter and you want to construct a DOM tree instead of dumping it to the OuputStream. Following code snippet shows how to create a StAX writer that builds a Document.

XMLOutputFactory xof = XMLOutputFactory.newInstance();

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

DocumentBuilder db = dbf.newDocumentBuilder();

Document doc = db.newDocument();

XMLStreamWriter writer = xof.createXMLStreamWriter(new DOMResult(doc));


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

venu

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today