Android???????
???????????? ???????[ 2013/6/4 10:00:26 ] ????????
????person.setName(new String(element.getFirstChild().getNodeValue()));
????}elseif("age".equals(childNode.getNodeName())){
????person.setAge(new Short(element.getFirstChild().getNodeValue()));
????}
????}
????}
????pers.add(person);
????}
????inStream.close();
????return pers;
????}
????}
????(3)???Pull?????????XML???
????PullPerson.java
????import java.io.File;
????import java.io.FileOutputStream;
????import java.io.InputStream;
????import java.util.ArrayList;
????import java.util.List;
????import org.xmlpull.v1.XmlPullParser;
????import org.xmlpull.v1.XmlSerializer;
????import android.os.Environment;
????import android.util.Xml;
????import com.sinber.domain.Person;
????publicclass PullPerson {
????publicstaticvoid save(List persons) throws Exception{
????XmlSerializer serializer = Xml.newSerializer();
????File file =new File(Environment.getExternalStorageDirectory()??"person.xml");
????FileOutputStream outStream =new FileOutputStream(file);
????serializer.setOutput(outStream??"UTF-8");
????serializer.startDocument("UTF-8"?? true);
????serializer.startTag(""?? "persons");
????for(Person person:persons){
????serializer.startTag(""?? "person"); //person
????serializer.attribute(""?? "id"?? ""+person.getId());
????serializer.startTag(""?? "name"); //name
????serializer.text(person.getName());
????serializer.endTag(""?? "name"); //name
????serializer.startTag(""?? "age"); //age
????serializer.text(person.getAge().toString());
????serializer.endTag(""?? "age");//age
????serializer.endTag(""?? "person"); //person
????}
????serializer.endTag(""?? "persons");
????serializer.endDocument();
????outStream.close();
????}
????publicstatic List getPersons() throws Exception{
????List persons =null;
????Person person =null;
????XmlPullParser parser= Xml.newPullParser();
????InputStream inStream = PullPersonService.class.getClassLoader().getResourceAsStream("person.xml");
????parser.setInput(inStream?? "UTF-8");
????int eventType = parser.getEventType(); //????????????
????while(eventType!=XmlPullParser.END_DOCUMENT){
????switch(eventType){
????case XmlPullParser.START_DOCUMENT:
????persons =new ArrayList();
????break;
????case XmlPullParser.START_TAG: //?????????
????if("person".equals(parser.getName())){
????person =new Person();
????person.setId(new Integer(parser.getAttributeValue(0)));
????}elseif(person!=null){
????if("name".equals(parser.getName())){
????person.setName(parser.nextText());
????}elseif("age".equals(parser.getName())){
????person.setAge(new Short(parser.nextText()));
????}
????}
????break;
????case XmlPullParser.END_TAG: //??????????
????if("person".equals(parser.getName())){
????persons.add(person);
????person =null;
????}
????break;
????default:
????break;
????}
????eventType = parser.next();
????}
????return persons;
????}
????}
???????????????????????ɡ?
????9.??????????????????Android?????????
??????(1)???е???ó???????????????飬Android???????????????????????ó???
????(2)Android??????????????????????????????????????????????????????????
????(3)??????????????Android ?????????????????????????????????????????????????????adt???????ant???????????????????????
????(4)??????鶼??????Ч????Android???????ó???????????????????Ч?????????????????????У???????????????????????????????
????10.?????????????head??д????????????????????
?????? ???????
????Node.java
????publicclass Node {
????private Integer count;
????private Node nextNode;
????public Node(){
????}
????public Node(int count){
????this.count =new Integer(count);
????}
????public Integer getCount() {
????return count;
????}
????publicvoid setCount(Integer count) {
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11