File tree 3 files changed +37
-2
lines changed
3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -278,4 +278,10 @@ golang的xml解析器自身还不支持BOM,所以本解析器还无法解析
278
278
- github仓库增加了构建服务,文档服务
279
279
- 补充用例,增加代码覆盖率到90%以上
280
280
281
+ #### 1.2.0 小版本改进,能力增强,bug解决
282
+
283
+ - 只是直接指定文件名加载文档或者保存文档:因为这两种场景也比较常见,比较实用
284
+ - 发现1.1.0版本新增函数引入的bug,可能导致对象被切片
285
+ - 将两个全局量PreetyPrint改名为Print在前:因为发现Print在前更容易记忆
286
+ - 完善文档
281
287
Original file line number Diff line number Diff line change 8
8
"io"
9
9
"unicode/utf8"
10
10
"container/list"
11
+ "os"
11
12
)
12
13
13
14
// XMLAttribute 是一个元素的属性的接口.
@@ -883,6 +884,34 @@ func LoadDocument(rd io.Reader) (XMLDocument, error) {
883
884
return nil , err
884
885
}
885
886
887
+ func LoadDocumentFromFile (name string ) (XMLDocument , error ) {
888
+ file , err := os .Open (name )
889
+ if nil != err {
890
+ return nil , err
891
+ }
892
+ defer file .Close ()
893
+
894
+ return LoadDocument (file )
895
+ }
896
+
897
+ // SaveDocumentToFile Print the xml-dom objects to the writer.
898
+ func SaveDocument (doc XMLDocument , writer io.Writer , options PrintOptions ) error {
899
+ doc .Accept (NewSimplePrinter (writer , options ))
900
+ return nil
901
+ }
902
+
903
+ // SaveDocumentToFile Print the xml-dom objects to the file.
904
+ func SaveDocumentToFile (doc XMLDocument , name string , options PrintOptions ) error {
905
+ file , err := os .Create (name )
906
+ if nil != err {
907
+ return err
908
+ }
909
+ defer file .Close ()
910
+
911
+ doc .Accept (NewSimplePrinter (file , options ))
912
+ return nil
913
+ }
914
+
886
915
// DefaultVisitor 这个类的目的是简化编写定制扫描的visitor,使得我们不需要定制XMLVisitor的所有接口
887
916
type DefaultVisitor struct {
888
917
EnterDocument func (XMLDocument ) bool
@@ -1345,5 +1374,5 @@ func EscapeText(w io.Writer, s []byte) error {
1345
1374
1346
1375
// Version 查询版本信息
1347
1376
func Version () string {
1348
- return "1.1 .0"
1377
+ return "1.2 .0"
1349
1378
}
Original file line number Diff line number Diff line change 1
- 1.1 .0
1
+ 1.2 .0
You can’t perform that action at this time.
0 commit comments