首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

[] JAXP解析命名空间示范以备将来查用

2012-10-21 
[] JAXP解析命名空间示例以备将来查用documentbuilderfactory factory documentbuilderfactory.newinsta

[] JAXP解析命名空间示例以备将来查用
    documentbuilderfactory factory = documentbuilderfactory.newinstance();        factory.setnamespaceaware(true);//开启命名空间        documentbuilder builder = factory.newdocumentbuilder();        document doc = builder.parse(new inputsource(new stringreader(result.tostring())));//用xml串构造源system.out.println(getasipreturnstring(doc));private node getsoapbody(document doc) {        nodelist bodynodelist = doc.getelementsbytagnamens(soap_ns, "body");        int bodynodelistlength = bodynodelist.getlength();        node body = null;        // 找到body        if (bodynodelistlength > 0) {            body = bodynodelist.item(0);        }        return body;    }private string getasipreturnstring(document doc) {        string asipreturnstring = null;        nodelist asipresponsenodelist = doc.getelementsbytagnamens(asip_ns, "callresponse");        int asipresponsenodelistlength = asipresponsenodelist.getlength();        node asipresponse = null;        if (asipresponsenodelistlength > 0) {            // 找到callresponse节点            asipresponse = asipresponsenodelist.item(0);            if (asipresponse != null) {                // 找到callreturn节点                node asipcallreturn = asipresponse.getfirstchild();                asipreturnstring = asipcallreturn.gettextcontent();            }        }        return asipreturnstring;    }
 

热点排行