- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoWriter.java
More file actions
Latest commit
28 lines (25 loc) · 1.05 KB
/
Copy pathDemoWriter.java
File metadata and controls
28 lines (25 loc) · 1.05 KB
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
importjava.util.HashMap;
importjava.io.IOException;
publicclassDemoWriter {
publicstaticvoidmain(String[] args) throwsXmlWriter.XmlwriterException {
XmlWriterxw = newXmlWriter();
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= newHashMap<>();
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");
}
}