436
技术社区[云栖]
解析XML字符串
怎么解析一个xml字符串?我不是第一次看到有人问这个问题了..汗
1.使用StringReader
Document doc = builder.parse( new java.io.StringReader(str)); 2.使用DocumentHelper.parseText()
String text = " <person> <name>James</name> </person> " ;
Document document = DocumentHelper.parseText(text); 3.最苯的方法:
Document doc = builder.parse( new ByteArrayInputStream(str.getBytes()));
文章转自庄周梦蝶 ,原文发布5.16
最后更新:2017-05-17 00:48:38