本文整理汇总了Java中org.dom4j.io.OutputFormat.setXHTML方法的典型用法代码示例。如果您正苦于以下问题:Java OutputFormat.setXHTML方法的具体用法?Java OutputFormat.setXHTML怎么用?Java OutputFormat.setXHTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.io.OutputFormat
的用法示例。
在下文中一共展示了OutputFormat.setXHTML方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prettyPrint
import org.dom4j.io.OutputFormat; //导入方法依赖的package包/类
/**
* Formats an {@link org.dom4j.Node} as a printable string
*
* @param node the Node to display
* @return a nicley-formatted String representation of the Node.
*/
public static String prettyPrint(Node node) {
StringWriter sw = new StringWriter();
OutputFormat format = OutputFormat.createPrettyPrint();
format.setXHTML(true);
//Default is false, this produces XHTML
HTMLWriter ppWriter = new HTMLWriter(sw, format);
try {
ppWriter.write(node);
ppWriter.flush();
} catch (Exception e) {
return ("Pretty Print Failed");
}
return sw.toString();
}
示例2: prettyPrint
import org.dom4j.io.OutputFormat; //导入方法依赖的package包/类
/**
* Description of the Method
*
*@param node Description of the Parameter
*@return Description of the Return Value
*@exception Exception Description of the Exception
*/
private String prettyPrint(Node node)
throws Exception {
StringWriter sw = new StringWriter();
OutputFormat format = OutputFormat.createPrettyPrint();
//These are the default formats from createPrettyPrint, so you needn't set them:
// format.setNewlines(true);
// format.setTrimText(true);
format.setXHTML(true);
//Default is false, this produces XHTML
HTMLWriter ppWriter = new HTMLWriter(sw, format);
ppWriter.write(node);
ppWriter.flush();
return sw.toString();
}