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()))); NodeList list = doc.getElementsByTagName("*"); for (int i = 0; i < list.getLength(); i++) { Element element = (Element) list.item(i); System.out.println(element); }//from w w w . j a v a 2 s . c o m }
From source file:Main.java
License:asdf
public static void main(String args[]) throws Exception { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); // Create the parser Document xmlDoc = builder.parse(new InputSource(new StringReader(xmlString))); Text text = xmlDoc.createTextNode("text"); }
From source file:Main.java
License:asdf
public static void main(String args[]) throws Exception { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); // Create the parser Document xmlDoc = builder.parse(new InputSource(new StringReader(xmlString))); Attr attr = xmlDoc.createAttribute("text"); }
From source file:Main.java
public static void main(String[] args) throws Exception { String xml = "<!DOCTYPE html><hml><img/></hml>"; SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); InputSource in = new InputSource(new StringReader(xml)); DefaultHandler2 myHandler = new DefaultHandler2() { @Override/*w w w .ja v a 2 s . co m*/ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { System.out.println("Element: " + qName); } @Override public void startDTD(String name, String publicId, String systemId) throws SAXException { System.out.println("DocType: " + name); } }; saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", myHandler); saxParser.parse(in, myHandler); }
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()))); NamedNodeMap notations = doc.getDoctype().getNotations(); for (int i = 0; i < notations.getLength(); i++) { Notation notation = (Notation) notations.item(i); String notationName = notation.getNodeName(); System.out.println(notationName); String notationPublicId = notation.getPublicId(); String notationSystemId = notation.getSystemId(); }//from w w w. ja va2s . c o m }
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()))); Element element = (Element) doc.getElementsByTagName("x").item(0); Node parent = element.getParentNode(); parent.removeChild(element);/*from w w w.ja v a 2s . co m*/ parent.normalize(); System.out.println(parent); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document document = factory.newDocumentBuilder().parse(new InputSource(new StringReader(getXMLData()))); Element e = document.getDocumentElement(); System.out.println(e);//from w w w. j a va 2s. com }
From source file:Main.java
License:asdf
public static void main(String args[]) throws Exception { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); // Create the parser Document xmlDoc = builder.parse(new InputSource(new StringReader(xmlString))); EntityReference ref = xmlDoc.createEntityReference("name"); }
From source file:Main.java
License:asdf
public static void main(String args[]) throws Exception { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); // Create the parser Document xmlDoc = builder.parse(new InputSource(new StringReader(xmlString))); DocumentFragment frag = xmlDoc.createDocumentFragment(); }
From source file:Main.java
License:asdf
public static void main(String args[]) throws Exception { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); // Create the parser Document xmlDoc = builder.parse(new InputSource(new StringReader(xmlString))); xmlDoc.setXmlStandalone(true);/*www . j a va2 s . c o m*/ }