XmlPullParserFactory factory; factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xpp = factory.newPullParser(); xpp.setInput( new StringReader ( "Hello World! " ) ); int eventType = xpp.getEventType();
res/raw フォルダにあるファイルを読み込む
XmlPullParserFactory factory; factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xpp = factory.newPullParser(); InputStream inputStream = getResources().openRawResource(R.raw.filename); xpp.setInput(inputStream ,"UTF-8"); int eventType = xpp.getEventType();
表示部分
while (eventType != XmlPullParser.END_DOCUMENT) { if(eventType == XmlPullParser.START_DOCUMENT) { System.out.println("Start document"); } else if(eventType == XmlPullParser.START_TAG) { System.out.println("Start tag "+xpp.getName()); } else if(eventType == XmlPullParser.END_TAG) { System.out.println("End tag "+xpp.getName()); } else if(eventType == XmlPullParser.TEXT) { System.out.println("Text "+xpp.getText()); } eventType = xpp.next(); } System.out.println("End document");
0 件のコメント:
コメントを投稿