用jdom来做需要jdom.jar
package com.king.utils;import java.io.IOException; 
import java.io.StringBufferInputStream; 
import java.io.UnsupportedEncodingException;import javax.xml.parsers.DocumentBuilder; 
import javax.xml.parsers.DocumentBuilderFactory; 
import javax.xml.parsers.ParserConfigurationException;import org.w3c.dom.DOMException; 
import org.w3c.dom.Document; 
import org.w3c.dom.Element; 
import org.w3c.dom.NodeList; 
import org.w3c.dom.Text; 
import org.xml.sax.SAXException;/** 
* @author Kane.D 

*/ public class XMLParser
{    private DocumentBuilderFactory domfac;    private Document doc;    //protected XMLField[][][] xMLFields;    public XMLParser()
    {
        domfac = DocumentBuilderFactory.newInstance();
    }    public void parse(String xMLString)
    {        try
        {
            DocumentBuilder dombuilder = domfac.newDocumentBuilder();            try
            {
                doc = dombuilder.parse(new StringBufferInputStream(xMLString));
            }
            catch (SAXException e)
            {
                // TODO Auto-generated catch block 
                e.printStackTrace();
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block 
                e.printStackTrace();
            }            Element root = doc.getDocumentElement();
            NodeList tables = root.getElementsByTagName("table");
            int countx = tables.getLength();
            //xMLFields = new XMLField[countx][][];
            Element table;
            for (int i = 0; i < countx; i++)
            {
                table = (Element) tables.item(i);
                NodeList records = table.getElementsByTagName("record");
                int county = records.getLength();
                //xMLFields[i] = new XMLField[county][];
                Element record;
                for (int j = 0; j < county; j++)
                {
                    record = (Element) records.item(j);
                    NodeList fields = record.getElementsByTagName("field");
                    int countz = fields.getLength();
                    //xMLFields[i][j] = new XMLField[countz];
                    Element field;
                    for (int k = 0; k < countz; k++)
                    {
                        //xMLFields[i][j][k] = new XMLField();
                        field = (Element) fields.item(k);
                        NodeList names = field.getElementsByTagName("name");
                        if (names.getLength() == 1)
                        {
                            Element name = (Element) names.item(0);
                            Text nametxt = (Text) name.getFirstChild();
                            //xMLFields[i][j][k].setName(nametxt.getNodeValue());
                        }                        NodeList types = field.getElementsByTagName("type");
                        if (types.getLength() == 1)
                        {
                            Element type = (Element) types.item(0);
                            Text typetxt = (Text) type.getFirstChild();
                            //xMLFields[i][j][k].setType(typetxt.getNodeValue());
                        }                        NodeList values = field.getElementsByTagName("value");
                        if (values.getLength() == 1)
                        {
                            Element value = (Element) values.item(0);
                            Text valuetxt = (Text) value.getFirstChild();
                            //System.out.println(new String(valuetxt.getNodeValue().getBytes("ISO-8859-1"), "GB2312"));
                            System.out.println(valuetxt.getNodeValue());
                            // xMLFields[i][j][k] 
                            // .setValue(new String(valuetxt.getNodeValue().getBytes("utf-8"),"gb2312")); 
                            //xMLFields[i][j][k].setValue(valuetxt.getNodeValue()
                            //        .toString());
                        }
                    }
                }
            }
        }
        catch (ParserConfigurationException e)
        {
            // TODO Auto-generated catch block 
            e.printStackTrace();
        }
        catch (DOMException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }//    public XMLField[][][] getXMLFields()
//    {
//        return xMLFields;
//    }
//
//    public void setXMLFields(XMLField[][][] fields)
//    {
//        xMLFields = fields;
//    }    public static void main(String[] args)
    {
        XMLParser sdd = new XMLParser();
        String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\"><channel><table>"
                + "<record><field><name>resultcaption</name><type>String</type><value>上海</value></field>"
                + "<field><name>中国</name><type>String</type><value>2007</value></field></record>"
                + "<record><field><name>resultyear</name><type>String</type><value>2007</value></field>"
                + "<field><name>resultfulFillRate</name><type>float</type><value>0.5</value></field>"
                + "</record></table><table><record><field><name>resultcaption</name><type>String</type>"
                + "<value>沈阳</value></field></record></table></channel></rss>";        sdd.parse(s);
//        XMLField[][][] xds = sdd.getXMLFields();
//
//        for (int i = 0; i < xds.length; i++)
//        {
//            for (int j = 0; j < xds[i].length; j++)
//            {
//                for (int k = 0; k < xds[i][j].length; k++)
//                {
//                    System.out.println(xds[i][j][k].getName());
//                    System.out.println(xds[i][j][k].getType());
//                    System.out.println(xds[i][j][k].getValue());
//                }
//            }
//        }
    }}