XML解析和生成之--pull(android内置)
?
- ?

- ?

- ?

- ?

- public class PersonServiceTest extends AndroidTestCase {private static final String TAG = "PersonServiceTest";public void testPullGetPersons() throws Throwable{InputStream inStream = getClass().getClassLoader().getResourceAsStream("target.xml");List<Person> persons = PULLPersonService.getPersons(inStream);for(Person person : persons){Log.i(TAG, person.toString());}}public void testSave() throws Throwable{List<Person> persons = new ArrayList<Person>();persons.add(new Person(34, "lili", (short)12));persons.add(new Person(25, "mimi", (short)32));persons.add(new Person(33, "xixi", (short)40));StringWriter writer = new StringWriter();PULLPersonService.save(persons, writer);Log.i(TAG, writer.toString());}}
用单元测试运行testPullGetPersons()方法,运行结果如下:
?
- ?
