List of utility methods to do XML String Transform
String | normXML(String s) norm XML String s2 = stripComment(s); String s3 = stripProlog(s2); try { TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); StringWriter buffer = new StringWriter(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); ... |
String | parseEventsToXML(String module, Hashtable keyvalues) parse Events To XML DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; try { docBuilder = dbfac.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element node = doc.createElement(module); ArrayList keysarray = new ArrayList(keyvalues.keySet()); for (int i = 0; i < keysarray.size(); i++) { ... |
String | parseToString(final Node node) parse To String String result = null; if (node != null) { node.normalize(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); StringWriter stringWriter = new StringWriter(); transformer.transform(new DOMSource(node), new StreamResult(stringWriter)); StringBuffer buffer = stringWriter.getBuffer(); result = buffer.toString(); ... |
Document | parseXmlFile(String filename, boolean validating, boolean namespaceAware) parse Xml File return parseXmlFile(new File(filename), validating, namespaceAware); |
String | readFile(String fileName) read File BufferedReader br = new BufferedReader(new FileReader(fileName)); try { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append("\n"); line = br.readLine(); ... |
String | readFile(String systemId) Reads a file. StringWriter result = new StringWriter(); transform(new StreamSource(systemId), new StreamResult(result), true); return checkResult(result, true); |
String | readURL(String urlStr) read URL return readURL(urlStr, false, false);
|
Source | readXMLFile(String xmlFileName) read XML File Source domSource = null; try { Document domDoc = builder.parse(new File(xmlFileName)); domSource = new javax.xml.transform.dom.DOMSource(domDoc); } catch (SAXParseException spe) { System.out .println("\n** Parsing error" + ", line " + spe.getLineNumber() + ", uri " + spe.getSystemId()); System.out.println(" " + spe.getMessage()); ... |
String | render(String name, byte[] xmldata) render StringWriter writer = new StringWriter(512); render(name, xmldata, writer); return writer.toString(); |
String | replaceLineSeparatorInternal(String string, String lineSeparator) Do not use outside of CDT. This method is a workaround for javax.xml.transform.Transformer not being able to specify the line separator. string = string.replace(LINE_SEPARATOR, lineSeparator);
return string;
|