pull解析
XmlPullParser parser = Xml.newPullParser();
InputStream is = getAssets().open("Books.xml");
parser.setInput(is, "utf-8");
int type = parser.getEventType();//0 != 1 true 0 != 0 false
List<Book> books = null;
Book book = null;
while(type != XmlPullParser.END_DOCUMENT){
switch (type) {
case XmlPullParser.START_TAG:
{
if("Books".equals(parser.getName())){
books = new ArrayList<Book>();
}else if("Book".equals(parser.getName())){
book = new Book();
}else if("name".equals(parser.getName())){
String name = parser.nextText();
book.setName(name);
}else if("price".equals(parser.getName())){
String price = parser.nextText();
book.setPrice(price);
}else if("author".equals(parser.getName())){
String author = parser.nextText();
book.setAuthor(author);
}
}
break;
case XmlPullParser.END_TAG:
if("Book".equals(parser.getName())){
books.add(book);
}
break;
}
type = parser.next();
}
return books;
} catch (Exception e) {
e.printStackTrace();
}
return null;
InputStream is = getAssets().open("Books.xml");
parser.setInput(is, "utf-8");
int type = parser.getEventType();//0 != 1 true 0 != 0 false
List<Book> books = null;
Book book = null;
while(type != XmlPullParser.END_DOCUMENT){
switch (type) {
case XmlPullParser.START_TAG:
{
if("Books".equals(parser.getName())){
books = new ArrayList<Book>();
}else if("Book".equals(parser.getName())){
book = new Book();
}else if("name".equals(parser.getName())){
String name = parser.nextText();
book.setName(name);
}else if("price".equals(parser.getName())){
String price = parser.nextText();
book.setPrice(price);
}else if("author".equals(parser.getName())){
String author = parser.nextText();
book.setAuthor(author);
}
}
break;
case XmlPullParser.END_TAG:
if("Book".equals(parser.getName())){
books.add(book);
}
break;
}
type = parser.next();
}
return books;
} catch (Exception e) {
e.printStackTrace();
}
return null;
相關文章
- Pull解析例項
- Android系列--DOM、SAX、Pull解析XMLAndroidXML
- Android中XML的解析--使用PULLAndroidXML
- Android之深入理解xml資料的pull解析AndroidXML
- Git pull errorGitError
- 簡單對比git pull和git pull --rebase的使用Git
- git pull命令模式Git模式
- Gitlab - Pull RequestGitlab
- Git撤銷本次pull rebase(變基) 回退到pull前的程式碼Git
- git pull 衝突解決Git
- git fetch & pull詳解Git
- GITLAB 中的 PULL REQUESTGitlab
- Pull Request 的命令列管理命令列
- [android]adb push/pullAndroid
- (轉載)git pull origin master與git pull --rebase origin master的區別GitAST
- Android的pull讀寫XMLAndroidXML
- Github的Pull Request命令列管理Github命令列
- git pull免密碼拉取Git密碼
- git pull衝突的解決方案Git
- gitlab Clone Pull Push 日誌資訊Gitlab
- Ubuntu git pull 出現Permission denied ErrorUbuntuGitError
- git修改檔案後無法push,需要先pull.並且pull後檔案有衝突Git
- git pull如果提示merge衝突,先進行git reset --hard origin/master 後再git pullGitAST
- Git fetch和git pull的區別Git
- Git 少用 Pull 多用 Fetch 和 MergeGit
- 如何將 Bitbucket 的 pull request 簽出到本地 reviewView
- [譯] Pull request review 的十大錯誤View
- git pull報“unable to update local ref”解決方案Git
- [提問交流]tortoisegit 小烏龜無法git pullGit
- window設定定時執行 git 更新(git pull)Git
- Git Fork Pull Request(PR)和Merge Request(MR)Git
- Git解決pull操作不成功問題Git
- 使用git pull提示refusing to merge unrelated historiesGit
- Git工作流指南:Pull Request工作流Git
- GIT團隊合作探討之二--Pull RequestGit
- docker無法拉取(pull)映象Error response from daemonDockerError
- openwrt docker pull 拉取映象是使用 http 代理DockerHTTP
- Docker: docker pull, wget, curl, git clone 等如何更快?DockerwgetGit