package usi.ipms.test;

import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

public class ParseCasXmlString {
public static void main(String[] args) {
String XmlString=""+
""+
""+
"
"+
""+
""+
""+
""+
""+
""+
"
"+
"
"+
"
";

try {
    Document document  = DocumentHelper.parseText(XmlString);
    //获取根节点元素,此处为
    Element node = document.getRootElement();
    //通过element()获得指定节点名称的节点,在这里是
    Element SessionID = node.element("SessionID");
    //获得所在节点的节点名称
    String elementName = SessionID.getName();
    //获取<西游记>节点所具有的属性,输入需要的属性名称id
    Attribute attribute = SessionID.attribute("sessionid");
    //获得属性文本 x001
    String txt = attribute.getText();
    System.out.println("SessionID:"+SessionID);
    System.out.println("elementName:"+elementName);
    System.out.println("attribute:"+attribute);
    System.out.println("txt:"+txt);
} catch (DocumentException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

}
}