KXMl中解决中文乱码问题
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-01 11:32 点击:次
public void verifyCredentials() throws Exception
{
InputStream is ;
HttpConnection hc = (HttpConnection) Connector.open(url);
try
{
int stateCode = hc.getResponseCode();
if(stateCode==200)
{
is = hc.openInputStream();
InputStreamReader in = new InputStreamReader(is,"UTF-8");
XmlParser parser = new XmlParser(in);
boolean parsing = true; //判断是否到达最后一个document标签
while(parsing)
{
ParseEvent event = parser.read();//
switch(event.getType())
{
case Xml.START_TAG : //处理开始标签tag
System.out.println("处理开始标签");
System.out.println("Tagname--"+((StartTag)event).getName()); //
break;
case Xml.END_TAG : //处理结束标签tag
System.out.println("处理结束标签111");
System.out.println("Tagname--"+event.toString());
break;
case Xml.END_DOCUMENT : //处理开始标签tag
System.out.println("结束处理标签,退出程序222222");
System.out.println("Tagname--"+event.toString());
parsing = false;
break;
case Xml.TEXT : //处理内容
System.out.println("内容---"+event.getText());
break;
}
}
}
&n
{
InputStream is ;
HttpConnection hc = (HttpConnection) Connector.open(url);
try
{
int stateCode = hc.getResponseCode();
if(stateCode==200)
{
is = hc.openInputStream();
InputStreamReader in = new InputStreamReader(is,"UTF-8");
XmlParser parser = new XmlParser(in);
boolean parsing = true; //判断是否到达最后一个document标签
while(parsing)
{
ParseEvent event = parser.read();//
switch(event.getType())
{
case Xml.START_TAG : //处理开始标签tag
System.out.println("处理开始标签");
System.out.println("Tagname--"+((StartTag)event).getName()); //
break;
case Xml.END_TAG : //处理结束标签tag
System.out.println("处理结束标签111");
System.out.println("Tagname--"+event.toString());
break;
case Xml.END_DOCUMENT : //处理开始标签tag
System.out.println("结束处理标签,退出程序222222");
System.out.println("Tagname--"+event.toString());
parsing = false;
break;
case Xml.TEXT : //处理内容
System.out.println("内容---"+event.getText());
break;
}
}
}
&n
相关新闻>>
- 发表评论
-
- 最新评论 更多>>