解析xml字符串出現java.net.MalformedURLException: no protocol的解決辦法

使用jdom解析xml字符串代碼以下java

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

運行時,拋異常java.net.MalformedURLException: no protocol......dom

解決辦法以下:ui

String xml="<root>......</root>";
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new ByteArrayInputStream(xml.getBytes()));
相關文章
相關標籤/搜索