日期:2014-05-20  浏览次数:20642 次

关于DOM解析xml,高分求教(顶者有分)
我想使用org.w3c.dom.*来解析xml
xml为:

<?xml   version= "1.0 "   encoding= "GBK "?>
<ROOT>
    <SEND>
        <SETYEAR> 2006 </SETYEAR>
        <SENDER> 001001001 </SENDER>
        <RECIPIENTS> 0020000001 </RECIPIENTS>
        <DATA   DATATYPE= "602 "   DESCRIPTION= "公务卡消费汇总信息 ">
            <OBJECT   NAME= "PAY_BILL "   ID= "1 "   DESCRIPTION= "支付凭证 ">
                <RECORD>
                    <ATTRIBUTE   NAME= "Pay_Bill_ID "   TYPE= " "   DESCRIPTION= "凭证号 "> 1012006-02001-00031 </ATTRIBUTE>
        <ATTRIBUTE   NAME= "PAY_BILL_INFO_ID "   TYPE= " "   DESCRIPTION= " "> 1012006-02001-00031 </ATTRIBUTE>
        <ATTRIBUTE   NAME= "CARD_COUNT "   TYPE= " "   DESCRIPTION= "笔数 "> 3 </ATTRIBUTE>
        <ATTRIBUTE   NAME= "RECEIVER_DISP_CODE "   TYPE= " "   DESCRIPTION= " "> 0020000001 </ATTRIBUTE>
        <ATTRIBUTE   NAME= "SET_YEAR "   TYPE= " "   DESCRIPTION= " "> 2006 </ATTRIBUTE>
        <ATTRIBUTE   NAME= "SUM_MONEY "   TYPE= " "   DESCRIPTION= "金额合计 "> 1580 </ATTRIBUTE>
        <ATTRIBUTE   NAME= "PAY_DETAIL_SUM_ID "   TYPE= "2 "   DESCRIPTION= "自增序号 "> 1 </ATTRIBUTE>
        <OBJECT   NAME= "PAY_DETAIL_SUM "   ID= "2 "   DESCRIPTION= " ">
                <RECORD>
            <ATTRIBUTE   NAME= "PAYEE_SUM_CODE "   TYPE= " "   DESCRIPTION= "还款账号 "> 5166189088801111 </ATTRIBUTE>
            <ATTRIBUTE   NAME= "PAY_BILL_INFO_ID "   TYPE= " "   DESCRIPTION= " "> 1012006-02001-00031 </ATTRIBUTE>
            <ATTRIBUTE   NAME= "PAYEE_SUM_NAME "   TYPE= " "   DESCRIPTION= " "> 瓦岚 </ATTRIBUTE>
            <ATTRIBUTE   NAME= "CARD_HOLDER "   TYPE= " "   DESCRIPTION= " "> 瓦岚 </ATTRIBUTE>
            <ATTRIBUTE   NAME= "TakeBack_Money "   TYPE= " "   DESCRIPTION= "还款金额 "> 276 </ATTRIBUTE>
            <ATTRIBUTE   NAME= "PAY_DETAIL_SUM_ID "   TYPE= "2 "   DESCRIPTION= "自增序号 "> 1 </ATTRIBUTE>
        </RECORD>
                <RECORD>
                    <ATTRIBUTE   NAME= "PAYEE_SUM_CODE "   TYPE= " "   DESCRIPTION= "还款账号 "> 5166189888801111 </ATTRIBUTE>