阅读436 返回首页    go 阿里云 go 技术社区[云栖]


解析XML字符串

怎么解析一个xml字符串?我不是第一次看到有人问这个问题了..汗

1.使用StringReader

 

None.gif Document doc  =  builder.parse(  new  java.io.StringReader(str)); 

2.使用DocumentHelper.parseText()

None.gif String text  =   " <person> <name>James</name> </person> " ; 
None.gifDocument document  =  DocumentHelper.parseText(text); 

3.最苯的方法:

 

None.gif Document doc   =   builder.parse(  new   ByteArrayInputStream(str.getBytes())); 
None.gif文章转自庄周梦蝶  ,原文发布5.16

最后更新:2017-05-17 00:48:38

  上一篇:go  势不可挡的猛兽——Dev Oops ? No , DevOps!
  下一篇:go  5月16日云栖精选夜读:从0到1构建大数据生态系列1:数据蛮荒中的拓荒之举