String字符串解析为xml

走着路睡觉
  • java
小于 1 分钟

public static Document loadXMLFromString(String xml) throws Exception
{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    InputSource is = new InputSource(new StringReader(xml));
    return builder.parse(is);
}
上次编辑于:
贡献者: zhaojingbo
Loading...