scala 加载与保存xml文档

 package scala_enhance.xml

 import scala.xml.XML
import scala.io.Source
import jdk.internal.org.xml.sax.InputSource
import java.io.FileInputStream
import java.io.InputStreamReader /**
* 读取与保存xml文档
*/
object Demo4 {
val path = "C:\\Users\\Administrator\\Desktop\\constant.xml"; //读取
val x1 = XML.loadFile(path);
println(x1); //使用java的io
val x2 = XML.load(new FileInputStream(path));
println(x2); val x3 = XML.load(new InputStreamReader(new FileInputStream(path),"utf-8"));
println(x3); //写出
val newPath = "C:\\Users\\Administrator\\Desktop\\constantXXX.xml";
XML.save(newPath,x3,"utf-8"); def main(args: Array[String]): Unit = { }
}
上一篇:C语言程序_管理系统


下一篇:文档对象模型操作xml文档