关于 android xmlSerializer 的问题
package com.pro.XMLHandle;
import java.io.StringWriter;
import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlSerializer;
import android.util.Log;
import com.pro.entity.PhotoInfo;
public class XMLInfoAdder {
private StringWriter stringWriter;
private XmlPullParserFactory factory;
private XmlSerializer xmlSerializer;
public String addPhotoInfo(PhotoInfo photoInfo) {
try {
stringWriter = new StringWriter();
factory = XmlPullParserFactory.newInstance();
xmlSerializer = factory.newSerializer();
xmlSerializer.setOutput(stringWriter);
String[] tags = new String[] { "photo", "street", "building",
"direction", "describe" };
Log.i("myInfo", photoInfo.getPhoto() + photoInfo.getStreet()
+ photoInfo.getBuilding() + photoInfo.getDirection()
+ photoInfo.getDescribe());
String[] texts = new String[] { photoInfo.getPhoto(),
photoInfo.getStreet(), photoInfo.getBuilding(),
photoInfo.getDirection(), photoInfo.getDescribe() };
xmlSerializer.startTag(null, "photoInfo");
for (int i = 0; i < tags.length; i++) {
Log.i("myInfo", i + "");
xmlSerializer.startTag(null, tags[i]);
xmlSerializer.text(texts[i]);
xmlSerializer.endTag(null, tags[i]);
}
xmlSerializer.endTag(null, "photoInfo");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(stringWriter.toString());
return stringWriter.toString();
}
public String addXMLHead() {
try {
stringWriter = new StringWriter();
factory = XmlPullParserFactory.newInstance();
xmlSerializer = factory.newSerializer();
xmlSerializer.setOutput(stringWriter);
xmlSerializer.startDocument("utf-8", true);
xmlSerializer
.startTag("http://picture_world.pro.com", "photoInfos");
} catch (Exception e) {
e.printStackTrace();
}
return stringWriter.toString();
}
public String addXMLTail() {
try {
stringWriter = new StringWriter();
factory = XmlPullParserFactory.newInstance();
xmlSerializer = factory.newSerializer();
xmlSerializer.setOutput(stringWriter);
xmlSerializer.endTag(null, "photoInfos");
xmlSerializer.endDocument();
} catch (Exception e) {
e.printStackTrace();
}
return stringWriter.toString();
}
}
为什么返回值为空呢 ?哪里错了吗?该得到的参数都不是空的 --------------------编程问答-------------------- 各位大侠帮帮忙 啊 顶起
--------------------编程问答-------------------- 顶顶顶 --------------------编程问答-------------------- 没人吗
补充:移动开发 , Android