WEB开发网
开发学院手机开发Android 开发 Android Pull解析xml 阅读

Android Pull解析xml

 2010-09-17 00:16:00 来源:WEB开发网   
核心提示:18. return price;19. }20. public void setPrice(float price) {21. this.price = price;22. }23. @Override24. public String toString(){25. return this.id+":&qu

18. return price;

19. }

20. public void setPrice(float price) {

21. this.price = price;

22. }

23. @Override

24. public String toString(){

25. return this.id+":"+this.name+":"+this.price;

26. }

27. }

public class Book {

private int id;

private String name;

private float price;

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public float getPrice() {

return price;

}

public void setPrice(float price) {

this.price = price;

}

@Override

public String toString(){

return this.id+":"+this.name+":"+this.price;

}

}

测试使用的是android的单元测试,代码如下:

Java代码

1. import java.io.InputStream;

2. import java.util.List;

3.

4. import android.test.AndroidTestCase;

5. import android.util.Log;

6.

7. import com.xtlh.cn.entity.Book;

8. import com.xtlh.cn.service.PullParseService;

9.

10. public class testPullParseService extends AndroidTestCase{

11. private static final String TAG = "testPullParseService";

12. public void testPull() throws Exception{

13. InputStream input = this.getClass().getClassLoader().getResourceAsStream("book.xml");

14. PullParseService pull = new PullParseService();

15. List< Book> books = pull.getBooks(input);

16. for(Book book : books){

17. Log.i(TAG,book.toString());

上一页  1 2 3 4 5 6  下一页

Tags:Android Pull 解析

编辑录入:coldstar [复制链接] [打 印]
赞助商链接