-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathGenerateStaxXml.java
More file actions
22 lines (20 loc) · 830 Bytes
/
Copy pathGenerateStaxXml.java
File metadata and controls
22 lines (20 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package xml;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class GenerateStaxXml {
public static void main(String[] args) throws FileNotFoundException, XMLStreamException {
XMLOutputFactory factory = XMLOutputFactory.newInstance();
XMLStreamWriter writer = factory.createXMLStreamWriter(new FileOutputStream("temp2.xml"));
writer.writeStartDocument();
writer.writeStartElement("root");
writer.writeStartElement("font");
writer.writeAttribute("size", "20");
writer.writeCharacters("TimesNewRoman");
writer.writeEndElement();
writer.writeEndElement();
writer.writeEndDocument();
}
}