sax

Posted cuthead

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sax相关的知识,希望对你有一定的参考价值。

package com.cuthead.thishitler;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;

import org.xml.sax.SAXException;

import android.util.Xml;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class MainActivity extends ListActivity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String[] str = {"ycy","ljw"};
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,str);
		hitler hitler2 = new hitler();
		String str2 = "heil";
		Reader reader = new StringReader(new String(str2));
        try {
			Xml.parse(reader, hitler2);
		} catch (IOException e) {
		} catch (SAXException e) {
		}
        setListAdapter(adapter);
    }
    }

  

package com.cuthead.thishitler;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

	public class hitler extends DefaultHandler {
		public static final String TAG_UPDATED = "updated";
		public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
			if (TAG_UPDATED.equals(localName)) {
			}
		}

	}

  

以上是关于sax的主要内容,如果未能解决你的问题,请参考以下文章

Sax 解析 XMl

JavaXML解析之SAX

Sax - ExpatParser$ParseException

java SAX解析器在工作代码更改后给出NullPointerException

Android中的SAX解析问题......空元素?

JAVA Apache POI 之sax 解析10万级大数量数据