日期:2014-05-19 浏览次数:20757 次
Object[] results = client.invoke("queryObjectOut", new Object[]{"01",jkxlh,"01111",queryXmlDoc}); String r = results[0].toString(); Document d = (Document) results[0]; NodeList nodeList = document.getElementsByTagName("student"); for(int i=0;i<nodeList.getLength();i++){ StringBuilder sb = new StringBuilder(); sb.append("姓名:"+document.getElementsByTagName("name").item(i).getFirstChild().getNodeValue()); sb.append(" , "); sb.append("年龄:"+document.getElementsByTagName("age").item(i).getFirstChild().getNodeValue()); sb.append(" , "); sb.append("性别:"+document.getElementsByTagName("sex").item(i).getFirstChild().getNodeValue()); sb.append(" , "); sb.append("地址:"+document.getElementsByTagName("address").item(i).getFirstChild().getNodeValue()); System.out.println(sb.toString());
System.out.println("返回XML"+d.getFirstChild().getFirstChild().getTextContent());
<?xml version="1.0" encoding="GBK"?> <information> <person> <name>张三</name> <age>19</age> <job>软件工程师</job> <employ-date> <day>12</day> <month>12</month> <year>1989</year> </employ-date> </person> <person> <name>李四</name> <age>33</age> <job>测试工程师</job> <employ-date> <day>10</day> <month>9</month> <year>2010</year> </employ-date> </person> <person> <name>王五</name> <age>28</age> <job>客服工程师</job> <employ-date> <day>6</day> <month>9</month> <year>2001</year> </employ-date> </person> <person> <name>赵六</name> <age>33</age> <job>售前工程师</job> <employ-date> <day>11</day> <month>7</month> <year>2000</year> </employ-date> </person> <person> <name>孙七</name> <age>27</age> <job>项目经理</job> <employ-date> <day>6</day> <month>8</month> <year>2010</year> </employ-date> </person> <person> <name>龙五</name> <age>39</age> <job>总经理</job> <employ-date> <day>3</day> <month>4</month> <year>1987</year> </employ-date> </person> </information>