List of usage examples for java.io StringReader StringReader
public StringReader(String s)
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); System.out.println(getAttributeValue(doc.getDocumentElement(), "attr")); System.out.println(documentToString(doc)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); System.out.println(hasAttribute(doc.getDocumentElement(), "value")); System.out.println(documentToString(doc)); }
From source file:Main.java
License:asdf
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); replacePerson(doc, "newName", "111111", "newEmail@email.com"); System.out.println(documentToString(doc)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); addComment(doc);//from w w w. j a v a2 s . c o m System.out.println(documentToString(doc)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); importName(doc, doc);/* w w w.java2s . co m*/ System.out.println(documentToString(doc)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); modifyTextByReplacement(doc);//w w w .j a v a2 s . co m System.out.println(documentToString(doc)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); modifyingTextbyCuttingandPasting(doc); System.out.println(documentToString(doc)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); editTextbyInsertionandReplacement(doc); System.out.println(documentToString(doc)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); dupAttributes(doc);// w w w . j av a2 s. co m System.out.println(documentToString(doc)); }
From source file:Main.java
public static void main(String[] args) throws Exception { XMLOutputFactory xof = XMLOutputFactory.newFactory(); StringWriter sw = new StringWriter(); XMLStreamWriter xsw = xof.createXMLStreamWriter(sw); xsw.writeStartDocument();// ww w. j av a2 s . c o m xsw.writeStartElement("foo"); xsw.writeCharacters("<>\"&'"); xsw.writeEndDocument(); String xml = sw.toString(); System.out.println(xml); // READ THE XML XMLInputFactory xif = XMLInputFactory.newFactory(); XMLStreamReader xsr = xif.createXMLStreamReader(new StringReader(xml)); xsr.nextTag(); // Advance to "foo" element System.out.println(xsr.getElementText()); }