XMLEventFactory: createStartElement(String prefix, String namespaceUri, String localName, Iterator attributes, Iterator namespaces)
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLOutputFactory;
public class MainClass {
public static void main(String[] args) throws Exception {
XMLEventFactory eventFactory = XMLEventFactory.newInstance();
XMLEventWriter writer = XMLOutputFactory.newInstance().createXMLEventWriter(System.out);
writer.add(eventFactory.createStartElement("ns1", "http://www.e.com/ns1", "sample", null,
null));
writer.add(eventFactory.createNamespace("ns1", "http://www.e.com/ns1"));
writer.add(eventFactory.createNamespace("ns2", "http://www.e.com/ns2"));
writer.add(eventFactory.createAttribute("ns2", "http://www.e.com/ns2", "attribute","true"));
writer.add(eventFactory.createEndDocument());
writer.flush();
}
}
Related examples in the same category
1. | XMLEventFactory: createAttribute(String localName, String value) | | |
2. | XMLEventFactory: createAttribute(String prefix, String namespaceURI, String localName, String value) | | |
3. | XMLEventFactory: createCharacters(String content) | | |
4. | XMLEventFactory: createEndDocument() | | |
5. | XMLEventFactory: createEndElement(String prefix, String namespaceUri, String localName) | | |
6. | XMLEventFactory: createNamespace(String prefix, String namespaceUri) | | |
7. | XMLEventFactory: createStartDocument(String encoding, String version) | | |
8. | XMLEventFactory: createStartElement(QName name, Iterator attributes, Iterator namespaces) | | |
9. | XMLEventFactory: createStartElement(String prefix, String namespaceUri, String localName) | | |