?? documenttoxml.java
字號(hào):
package cn.com.iaspec.workflow.manage.managetree;
/**
* <p>Title:解析XML </p>
*
* <p>Description: 深圳市勞動(dòng)仲裁信息管理系統(tǒng)</p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: 永泰軟件工程有限公司</p>
*
* @author syj
* @version 1.0
*/
import org.apache.xml.serialize.*;
import org.w3c.dom.*;
public class DocumentToXml{
public DocumentToXml(){}
/**
* docToXML
* generate the XML text by the Document
* @param doc Document the Document need to be generated
* @return String the generated XML text
*/
public static String docToXML(Document doc){
return docToXML(doc,null,true);
}
public static String docToXML(Document doc,boolean bFormat){
return docToXML(doc,null,bFormat);
}
public static String docToXML(Document doc,String xsldoc,boolean bFormat){
OutputFormat format=new OutputFormat(doc,"GB2312",bFormat); //Serialize DOM
java.io.StringWriter stringOut=new java.io.StringWriter(); //Writer will be a String
XMLSerializer serial=new XMLSerializer(stringOut,format);
try{
serial.asDOMSerializer(); // As a DOM Serializer
if(xsldoc!=null&&xsldoc.trim().length()>0){
serial.processingInstruction("xml:stylesheet",
"href=\""+xsldoc+"\" type=\"text/xsl\"");
}
serial.serialize(doc.getDocumentElement());
}
catch(Exception ignore){}
return stringOut.toString();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -