本文整理匯總了Java中org.w3c.tidy.Tidy.setXmlTags方法的典型用法代碼示例。如果您正苦於以下問題:Java Tidy.setXmlTags方法的具體用法?Java Tidy.setXmlTags怎麽用?Java Tidy.setXmlTags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.tidy.Tidy
的用法示例。
在下文中一共展示了Tidy.setXmlTags方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: cleanNfo
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
* Try to clean the NFO(XML) content with JTidy.
*
* @param sourceNfoContent
* the XML content to be cleaned
* @return the cleaned XML content (or the source, if any Exceptions occur)
*/
public static String cleanNfo(String sourceNfoContent) {
try {
Tidy tidy = new Tidy();
tidy.setInputEncoding("UTF-8");
tidy.setOutputEncoding("UTF-8");
tidy.setWraplen(Integer.MAX_VALUE);
tidy.setXmlOut(true);
tidy.setSmartIndent(true);
tidy.setXmlTags(true);
tidy.setMakeClean(true);
tidy.setForceOutput(true);
tidy.setQuiet(true);
tidy.setShowWarnings(false);
StringReader in = new StringReader(sourceNfoContent);
StringWriter out = new StringWriter();
tidy.parse(in, out);
return out.toString();
}
catch (Exception e) {
}
return sourceNfoContent;
}
示例2: cleanXMLData
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String cleanXMLData(String data) throws UnsupportedEncodingException {
// data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+data;
Tidy tidy = new Tidy();
tidy.setInputEncoding("UTF-8");
tidy.setOutputEncoding("UTF-8");
tidy.setWraplen(Integer.MAX_VALUE);
// tidy.setPrintBodyOnly(true);
tidy.setXmlOut(true);
tidy.setXmlTags(true);
tidy.setSmartIndent(true);
tidy.setMakeClean(true);
tidy.setForceOutput(true);
ByteArrayInputStream inputStream = new ByteArrayInputStream(data.getBytes("UTF-8"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
tidy.parseDOM(inputStream, outputStream);
return outputStream.toString("UTF-8");
}
示例3: makeTidyParser
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
* Create a Tidy parser with the specified settings.
*
* @param quiet - set the Tidy quiet flag?
* @param showWarnings - show Tidy warnings?
* @param isXml - treat the content as XML?
* @param stringWriter - if non-null, use this for Tidy errorOutput
* @return the Tidy parser
*/
public static Tidy makeTidyParser(boolean quiet, boolean showWarnings, boolean isXml, StringWriter stringWriter) {
Tidy tidy = new Tidy();
tidy.setInputEncoding("UTF8");
tidy.setOutputEncoding("UTF8");
tidy.setQuiet(quiet);
tidy.setShowWarnings(showWarnings);
tidy.setMakeClean(true);
tidy.setXmlTags(isXml);
if (stringWriter != null) {
tidy.setErrout(new PrintWriter(stringWriter));
}
return tidy;
}
示例4: beautyHTML
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
private String beautyHTML(String html) throws UnsupportedEncodingException {
Tidy tidy = new Tidy();
tidy.setInputEncoding("UTF-8");
tidy.setOutputEncoding("UTF-8");
tidy.setWraplen(Integer.MAX_VALUE);
tidy.setXmlOut(true);
tidy.setXmlTags(true);
tidy.setSmartIndent(true);
ByteArrayInputStream inputStream = new ByteArrayInputStream(html.getBytes("UTF-8"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Document doc = tidy.parseDOM(inputStream, null);
tidy.pprint(doc, outputStream);
return outputStream.toString("UTF-8");
}
示例5: initializeTidyBuilder
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
* Initializes the tidy document builder.
*/
private void initializeTidyBuilder() {
tidyBuilder = new Tidy();
tidyBuilder.setInputEncoding("UTF-8");
tidyBuilder.setOutputEncoding("UTF-8");
tidyBuilder.setXmlOut(true);
tidyBuilder.setShowWarnings(false);
tidyBuilder.setQuiet(true);
tidyBuilder.setDropEmptyParas(false);
tidyBuilder.setTidyMark(false);
tidyBuilder.setFixComments(false);
tidyBuilder.setTrimEmptyElements(false);
tidyBuilder.setJoinStyles(false);
tidyBuilder.setXmlTags(true); // important, otherwise jtidy manipulates the markup
}
示例6: convertToXMLOLD
import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String convertToXMLOLD(String xml){
//======================================
// String newXML = xml;
// String xml1 = "";
// String xml2 = "";
// String html = "";
// if (xml.indexOf("<text>")>-1) {
// xml1 = xml.substring(0,xml.indexOf("<text>")+6);
// xml2 = xml.substring(xml.indexOf("</text>"));
// html = xml.substring(xml.indexOf("<text>")+6,xml.indexOf("</text>"));
// }
// if (xml.indexOf("<comment>")>-1) {
// xml1 = xml.substring(0,xml.indexOf("<comment>")+9);
// xml2 = xml.substring(xml.indexOf("</comment>"));
// html = xml.substring(xml.indexOf("<comment>")+9,xml.indexOf("</comment>"));
// }
// if (xml.indexOf("<description>")>-1) {
// xml1 = xml.substring(0,xml.indexOf("<description>")+13);
// xml2 = xml.substring(xml.indexOf("</description>"));
// html = xml.substring(xml.indexOf("<description>")+13,xml.indexOf("</description>"));
// }
// if (html.length()>0) { // xml is html
// html = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'><head><title></title></head><body>" +html+"</body>";
StringReader in = new StringReader(xml);
StringWriter out = new StringWriter();
Tidy tidy = new Tidy();
tidy.setInputEncoding("UTF-8");
tidy.setOutputEncoding("UTF-8");
tidy.setWraplen(Integer.MAX_VALUE);
tidy.setPrintBodyOnly(true);
tidy.setMakeClean(true);
// tidy.setForceOutput(true);
tidy.setSmartIndent(true);
tidy.setXmlTags(true);
tidy.setXmlOut(true);
// tidy.setWraplen(0);
tidy.parseDOM(in, out);
String newXML = out.toString();
// newXML = xml1+newHTML.substring(newHTML.indexOf("<body>")+6,newHTML.indexOf("</body>"))+xml2;
// } else {
// newXML =xml;
// }
// return newXML;
return newXML;
}