List of utility methods to do XML Document Parse
Document | parseDocumentr(File f) parse Documentr return getDocumentBuilder().parse(f);
|
Document | parseFileToDocument(File f) Read the contents of the specified file into a DOM document DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance();
docBuilderFact.setNamespaceAware(true);
DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder();
Document document = docBuilder.parse(f);
return document;
|
HTMLDocument | parseHTMLDocument(String paramString) parse HTML Document StringReader localStringReader = new StringReader(paramString); HTMLEditorKit localHTMLEditorKit = new HTMLEditorKit(); HTMLDocument localHTMLDocument = (HTMLDocument) localHTMLEditorKit.createDefaultDocument(); localHTMLDocument.putProperty("IgnoreCharsetDirective", Boolean.TRUE); try { localHTMLEditorKit.read(localStringReader, localHTMLDocument, 0); } catch (IOException localIOException) { System.out.println(localIOException); ... |
void | parseInitMap(InputStream in, DocumentBuilder builder, Map parse Init Map Document doc = builder.parse(in); NodeList nodelist = doc.getElementsByTagName("item"); for (int i = 0; i < nodelist.getLength(); i++) { Node node = nodelist.item(i); NodeList list = node.getChildNodes(); String name = null; for (int j = 0; j < list.getLength(); j++) { Node n = list.item(j); ... |
Document[] | parseMultipleWorkouts(Document doc) parse Multiple Workouts NodeList activities = doc.getElementsByTagName("Activity"); int activitiesLength = activities.getLength(); if (activitiesLength == 1) return new Document[] { doc }; else { Document[] docs = new Document[activitiesLength]; for (int i = 0; i < activitiesLength; ++i) { Node n = activities.item(i); ... |
void | parseResponse(InputSource is, DocumentBuilder documentBuilder) parse Response try { documentBuilder.parse(is); } catch (SAXException e) { System.err.println(e.getLocalizedMessage()); } catch (IOException e) { System.err.println(e.getLocalizedMessage()); |
Document | parseToDocument(InputStream is, boolean debugModeEnabled) parse To Document DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(is); if (debugModeEnabled) System.out.println("Body:\n" + serializeDocument(document) + "\n"); return document; |
void | parseXMLDoc(Element element, Document doc, Map parse XML Doc NodeList child = null; if (element == null) { child = doc.getChildNodes(); } else { child = element.getChildNodes(); for (int j = 0; j < child.getLength(); j++) { if (child.item(j).getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) { ... |
String | parseXmlDocToString(Document xmlDoc) parse Xml Doc To String System.setProperty(DOMImplementationRegistry.PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl"); final DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); final DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS"); final LSSerializer writer = impl.createLSSerializer(); writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); writer.getDomConfig().setParameter("xml-declaration", true); return writer.writeToString(xmlDoc); ... |
Document | parseXmlDocument(InputStream is, boolean namespaceAware) parse Xml Document DocumentBuilder docBuilder = buildDocumentBuilder(namespaceAware);
Document doc = docBuilder.parse(is);
doc.getDocumentElement().normalize();
return doc;
|