-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemoWriter.java
28 lines (25 loc) · 1.05 KB
/
DemoWriter.java
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
import java.util.HashMap;
import java.io.IOException;
public class DemoWriter {
public static void main(String[] args) throws XmlWriter.XmlwriterException {
XmlWriter xw = new XmlWriter();
xw.writeStartDocument("utf-8"); // Document Encoding.
xw.writeStartElement("Students");
xw.writeStartElement("Student");
xw.writeStartEndElement("Name","Jenifer");
xw.writeStartEndElement("Grade","Five");
xw.writeStartEndElement("Roll","010111");
xw.writeEndElement();
xw.writeStartElement("Student");
HashMap<String,String > attributes= new HashMap<>();
attributes.put("father","Doe");
attributes.put("mother","Cameron Diaz");
xw.writeStartEndElementWithAttr("Parents","Yes",attributes);
xw.writeStartEndElement("Name","Jhon Doe");
xw.writeStartEndElement("Grade","Five");
xw.writeStartEndElement("Roll","010112");
xw.writeEndElement();
xw.writeEndElement();
xw.SaveDocument("D:\\\\Projects\\\\XMLFiles","DemoFile");
}
}