本文整理汇总了Java中org.apache.xml.serialize.Method类的典型用法代码示例。如果您正苦于以下问题:Java Method类的具体用法?Java Method怎么用?Java Method使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Method类属于org.apache.xml.serialize包,在下文中一共展示了Method类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToXHTML
import org.apache.xml.serialize.Method; //导入依赖的package包/类
public static String convertToXHTML(String in) {
SAXParser parser = new SAXParser();
InputSource source;
OutputFormat outputFormat = new OutputFormat();
try {
//parser.setProperty("http://cyberneko.org/html/properties/default-encoding", charset);
parser.setProperty("http://cyberneko.org/html/properties/names/elems", "lower");
outputFormat.setOmitDocumentType(true);
outputFormat.setOmitXMLDeclaration(true);
outputFormat.setMethod(Method.XHTML);
outputFormat.setIndenting(true);
StringReader sr = new StringReader(in);
StringWriter sw = new StringWriter();
source = new InputSource(sr);
parser.setContentHandler(new XMLSerializer(sw, outputFormat));
parser.parse(source);
return sw.toString();
} catch (Exception ex) {
new ExceptionDialog(ex);
}
return null;
}
示例2: convertToXHTML
import org.apache.xml.serialize.Method; //导入依赖的package包/类
public static String convertToXHTML(String in) {
SAXParser parser = new SAXParser();
InputSource source;
OutputFormat outputFormat = new OutputFormat();
try {
//parser.setProperty("http://cyberneko.org/html/properties/default-encoding", charset);
parser.setProperty("http://cyberneko.org/html/properties/names/elems", "lower");
outputFormat.setOmitDocumentType(true);
outputFormat.setOmitXMLDeclaration(true);
outputFormat.setMethod(Method.XHTML);
outputFormat.setIndenting(true);
StringReader sr = new StringReader(in);
StringWriter sw = new StringWriter();
source = new InputSource(sr);
parser.setContentHandler(new XMLSerializer(sw, outputFormat));
parser.parse(source);
return sw.toString();
}
catch (Exception ex) {
new ExceptionDialog(ex);
}
return null;
}
示例3: convertToXHTML
import org.apache.xml.serialize.Method; //导入依赖的package包/类
public static String convertToXHTML(String in) {
SAXParser parser = new SAXParser();
InputSource source;
OutputFormat outputFormat = new OutputFormat();
try {
// parser.setProperty("http://cyberneko.org/html/properties/default-encoding",
// charset);
parser.setProperty("http://cyberneko.org/html/properties/names/elems", "lower");
outputFormat.setOmitDocumentType(true);
outputFormat.setOmitXMLDeclaration(true);
outputFormat.setMethod(Method.XHTML);
outputFormat.setIndenting(true);
StringReader sr = new StringReader(in);
StringWriter sw = new StringWriter();
source = new InputSource(sr);
parser.setContentHandler(new XMLSerializer(sw, outputFormat));
parser.parse(source);
return sw.toString();
} catch (Exception ex) {
new ExceptionDialog(ex);
}
return null;
}
示例4: nodeToString
import org.apache.xml.serialize.Method; //导入依赖的package包/类
protected String nodeToString(Node node) {
StringWriter stringOut = new StringWriter();
OutputFormat format = new OutputFormat(Method.XML, null, false);
format.setOmitXMLDeclaration(true);
NodeXMLSerializer serial = new NodeXMLSerializer(stringOut, format);
try {
serial.serializeNode(node);
} catch (IOException e) {
throw new RuntimeException(e);
}
return stringOut.toString();
}