public interface XmlOutputMethods
protected static final String DEFAULT_ROOT_ELEMENT = "root-elem"; public String asXML() { String rootElementName = DEFAULT_ROOT_ELEMENT; return asXML(rootElementName); } public String asXML(String rootElementName) { String result = ""; Document document = asDocument(rootElementName); result = document.asXML(); return result; } public Element asElement() { String rootElementName = DEFAULT_ROOT_ELEMENT; return asElement(rootElementName); } public Element asElement(String rootElementName) { return (Element) asDocument(rootElementName).getRootElement().detach(); } public Document asDocument() { String rootElementName = DEFAULT_ROOT_ELEMENT; return asDocument(rootElementName); } public Document asDocument(String rootElementName) { Document document = DocumentHelper.createDocument(); Element root = document.addElement( rootElementName ); root.addComment(ConfigFetch.getSaveAsCommentForXML()); ... return document; }As you notice only one has to be implemented, the others just call each other.
Modifier and Type | Method and Description |
---|---|
org.dom4j.Document |
asDocument() |
org.dom4j.Document |
asDocument(java.lang.String rootElementName) |
org.dom4j.Element |
asElement() |
org.dom4j.Element |
asElement(java.lang.String rootElementName) |
java.lang.String |
asXML()
Este problema foi resolvido com a versão 1.6.1 do DOM4J.
|
java.lang.String |
asXML(java.lang.String rootElementName)
Este problema foi resolvido com a versão 1.6.1 do DOM4J.
|
java.lang.String asXML()
FileUtil.saveToFile(String, String)
e afins. Isto porque ao gravar como UTF-8
os caracteres são adulterados guardando por exemplo "é" em 2 caracteres (ou seja pega nos dois caracteres UTF-8 e
transforma-os em 2 UTF-8s).java.lang.String asXML(java.lang.String rootElementName)
FileUtil.saveToFile(String, String)
e afins. Isto porque ao gravar como UTF-8
os caracteres são adulterados guardando por exemplo "é" em 2 caracteres (ou seja pega nos dois caracteres UTF-8 e
transforma-os em 2 UTF-8s).rootElementName
- org.dom4j.Element asElement()
org.dom4j.Element asElement(java.lang.String rootElementName)
rootElementName
- org.dom4j.Document asDocument()
org.dom4j.Document asDocument(java.lang.String rootElementName)
rootElementName
- Copyright © 2004-2014 FEUP-LSTS and Neptus developers. All Rights Reserved.