62,614
社区成员
发帖
与我相关
我的任务
分享
<pma_xml_export xmlns:pma="http://www.phpmyadmin.net/some_doc_url/" version="1.0">
<!--
- Structure schemas
-->
<pma:structure_schemas>
<pma:database name="test" collation="latin1_swedish_ci" charset="latin1">
<pma:table name="light">
CREATE TABLE `light` ( `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `light` int(11) NOT NULL, UNIQUE KEY `time` (`time`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
</pma:table>
</pma:database>
</pma:structure_schemas>
<!--
- 数据库: 'test'
-->
<database name="test">
<!-- 表 light -->
<table name="light">
<column name="time">2015-02-13 00:00:00</column>
<column name="light">13</column>
</table>
<table name="light">
<column name="time">2015-02-14 00:00:00</column>
<column name="light">14</column>
</table>
</database>
</pma_xml_export>
public static List<weatherInfo> getPersons(String buffer) throws IOException{
List<weatherInfo> infos = null;
weatherInfo info = null;
XmlPullParser pullParser = Xml.newPullParser();
try {
pullParser.setInput(tInputStringStream,"UTF-8");
int event = pullParser.getEventType();
while(event!=XmlPullParser.END_DOCUMENT){
switch (event) {
case XmlPullParser.START_DOCUMENT:
infos = new ArrayList<weatherInfo>();
break;
case XmlPullParser.START_TAG:
if("table".equals(pullParser.getName())){
info = new weatherInfo();
}
if("column".equals(pullParser.getName())){
String att=pullParser.getAttributeValue(0);
if("time".equals(att)){
String time = pullParser.nextText();
Log.d("io","light:"+time);
info.setTime(time);
}
else if("light".equals(att)){
String light = pullParser.nextText();
Log.d("io","light:"+light);
info.setLight(light);
}
}
break;
case XmlPullParser.END_TAG:
if("table".equals(pullParser.getName())){
infos.add(info);
Log.d("io","info"+info.light);
info = null;
}
break;
}
event = pullParser.next();
}
}
catch (XmlPullParserException e) {
e.printStackTrace();
}
for (int i=0;i<infos.size();i++)
{
System.out.println("test"+ infos.get(i).getLight());
}
return infos;
}
}