感謝大家教會我用dom解析xml  現在想了解下sax解析 例子如下 最好寫出代碼 謝謝<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
<SOAP-ENV:Header> 
<ServiceName SOAP-ENV:mustUnderstand="1" xmlns="urn:go.jp:xmlns:AAA.BBBB.Service">SERVICE </ServiceName> 
</SOAP-ENV:Header> 
<SOAP-ENV:Body> 
<Data xmlns="urn:go.jp:xmlns:AAA.BBBB.Service"> 
<Tbl name="SYSIN"> 
<Rec> 
<Item name="Date">20080527 </Item> 
<Item name="PersonalNo">01234567 </Item> 
</Rec> 
</Tbl> 
</Data> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope>

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【redcellx】截止到2008-07-23 16:42:02的历史汇总数据(不包括此帖):
    发帖的总数量:4                        发帖的总分数:110                      每贴平均分数:27                       
    回帖的总数量:3                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:4                        结贴的总分数:110                      
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:100.00%                  
    无满意结贴率:0.00  %               无满意结分率:0.00  %                  
    敬礼!
      

  2.   

    这么短效的xml用sax没有必要,直接dom4j或者dom就可以了!
      

  3.   

    想學學SAX  希望大家幫忙 謝謝
      

  4.   

    想解析出來的值為:
    SOAP-ENVhttp://schemas.xmlsoap.org/soap/envelope/urn:go.jp:xmlns:AAA.BBBB.Service(<ServiceName SOAP-ENV:mustUnderstand="1" xmlns="urn:go.jp:xmlns:AAA.BBBB.Service">)mustUnderstand="1"SERVICEurn:go.jp:xmlns:AAA.BBBB.Service(<Data xmlns="urn:go.jp:xmlns:AAA.BBBB.Service">)SYSINDate和20080527(<Item name="Date">20080527 </Item>)PersonalNo和01234567(<Item name="PersonalNo">01234567 </Item>)謝謝大家了
      

  5.   

    import org.xml.sax.*; 
    import javax.xml.parsers.*; 
    import java.io.IOException; 
    import java.util.Vector;
     
    public class SAX extends org.xml.sax.helpers.DefaultHandler
    {  
    private double totalPrice = 0.00; 
    private StringBuffer content = new StringBuffer(); 
    private Vector numberV = new Vector(); 
    public SAX() {} 
    public static void main(String[] args) throws Exception

     SAX sax = new  SAX(); 
     sax.createParser(); 

    public void createParser() throws Exception


    SAXParserFactory spf = SAXParserFactory.newInstance(); 
    spf.setValidating(false); 
    SAXParser sp = spf.newSAXParser(); 
    XMLReader xr = sp.getXMLReader(); 
    xr.setContentHandler(this); 
    //下面改成项目文件下的xml文件名
    xr.parse("simple.xml"); 
    }  
    //元素开始时的操作
    public void startElement(String namespaceURI, String localName, String rawName, Attributes atts) throws SAXException 
    {
    System.out.println(rawName);
    System.out.println(atts.getValue(0)); }  
    //元素结束时的方法 
    public void endElement(String uri, String localName, String qName) throws SAXException
    {  
    }   
    //文档读完的操作
    public void endDocument() throws SAXException 
    {  

      

  6.   

    就上面的xml例子來說 public void startElement(String namespaceURI, String localName, String rawName, Attributes atts) throws SAXException 中 String namespaceURI, String localName, String rawName, Attributes atts 分別代表哪個?
      

  7.   

    想解析出來的值為: 
    SOAP-ENV http://schemas.xmlsoap.org/soap/envelope/ urn:go.jp:xmlns:AAA.BBBB.Service( <ServiceName SOAP-ENV:mustUnderstand="1" xmlns="urn:go.jp:xmlns:AAA.BBBB.Service">) mustUnderstand="1" SERVICE urn:go.jp:xmlns:AAA.BBBB.Service( <Data xmlns="urn:go.jp:xmlns:AAA.BBBB.Service">) SYSIN Date和20080527( <Item name="Date">20080527 </Item>) PersonalNo和01234567( <Item name="PersonalNo">01234567 </Item>) 謝謝大家了 
      

  8.   


         *@param uri The Namespace URI, or the empty string if the
         *        element has no Namespace URI or if Namespace
         *        processing is not being performed.
         *@param localName The local name (without prefix), or the
         *        empty string if Namespace processing is not being
         *        performed.
         *@param qName The qualified name (with prefix), or the
         *        empty string if qualified names are not available.
         *@param attributes The attributes attached to the element.  If
         *        there are no attributes, it shall be an empty
         *        Attributes object.