感謝大家教會我用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>
<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>
解决方案 »
- substance的使用
- 新人问题:静态域或方法可以被其他类共享吗?
- faint!XMLOutputer总报错!
- 在Jcreator下,System.in.read()不需要import.io.*??我没有import也能用为何啊?
- 请大家帮忙给一个n行n列在applet实现功能的一个静态表格的代码
- linux下Java调用其他程序
- 我做了一个APPLET,可是在IE中却不出运行结果???在线等待!!!
- 高分求教:谁能用贪心算法来解决这个问题?在线等待
- 请问JAVA的开发环境是什么? 那里有下载?
- 请问可不可以显示一个html源代码的字符串
- 怎么才能快速比较字符串,取出分隔符最后的字符
- 怎么让drawLine()的极坐标变成contentPane的极坐标?
楼主【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 %
敬礼!
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>)謝謝大家了
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
{
}
}
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>) 謝謝大家了
*@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.