xml文件解析工具
public class XmlParse
{
DocumentBuilderFactory dbf;
DocumentBuilder db;
Document doc;
public Document getDocument() {
return doc;
}
public String doc2String() {
return doc2String(doc);
}
//
public static String doc2String(Document doc) {
String str = null;
try
{
DOMSource source = new DOMSource(doc);
StringWriter writer = new StringWriter();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty("encoding", "UTF-8");
transformer.setOutputProperty("indent", "no");
transformer.transform(source, new StreamResult(writer));
str = writer.getBuffer().toString();
str = ExpressionDeal.replace(str, "\r", "");
str = ExpressionDeal.replace(str, "\n", "");
return str;
} catch (Exception e) {
PosLog.getLog("XmlParse"