使用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()));
时间: 2024-10-10 04:02:36