首页 > 代码库 > 解析xml字符串出现java.net.MalformedURLException: no protocol的解决办法

解析xml字符串出现java.net.MalformedURLException: no protocol的解决办法

使用jdom解析xml字符串代码如下

String xml = "<root>......</root>";SAXBuilder builder = new SAXBuilder();Document doc = builder.build(xml);

运行时,抛异常java.net.MalformedURLException: no protocol......

解决办法如下:

String xml="<root>......</root>";SAXBuilder builder = new SAXBuilder();Document doc = builder.build(new ByteArrayInputStream(xml.getBytes()));

 

解析xml字符串出现java.net.MalformedURLException: no protocol的解决办法