DOM4J解析问题!
代码如下:
import java.util.Iterator;
import java.util.List;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
public class att {
public void findLinks(String xmlStr){
try{
Document document=DocumentHelper.parseText(xmlStr);
List list = document.selectNodes("phase_table");
for (Iterator iter = list.iterator(); iter.hasNext();) {
Attribute attribute = (Attribute) iter.next();
String name= attribute.getName();
String value = attribute.getValue();
System.out.println(name+":"+value);
}
}catch(DocumentException e){
System.out.println(e.getMessage());
}
}
public static void main(String[] args) throws DocumentException {
String xmlStr="<?xml version='1.0' encoding='GB2312'?><WebResponse><method><result total='3' per_list='30' row_from='3'><phase_table Cata_id='2006050101' phase_time='20060501110101'></phase_table></result></method></WebResponse>";
att ss=new att();
ss.findLinks(xmlStr);
}
}
编译时没错,运行时没有任何显示!
想请教各位原因,请大家指点!谢谢!