java获取XML数据

public static void main(String[] args) throws DocumentException {
    String a="True110233631";
    Document document = DocumentHelper.parseText(a);// 将字符串转为XML
    Element rootElement = document.getRootElement();
    String FileName = rootElement.elementTextTrim("FileName");
    System.out.println(FileName);
}

 

public static void main(String[] args) throws DocumentException {
    String a="True
1102336442019/6/17 19:37:537.27.27.21301806
"; Document document = DocumentHelper.parseText(a);// 将字符串转为XML Element rootElement = document.getRootElement().element("Articles").element("Article"); String Article=rootElement.attributeValue("id"); System.out.println(Article); }

你可能感兴趣的:(原创)