我是Android编程的新手,并且面临plistParsing的问题。以下代码适用于2.1,2.2,但是当我测试3.0“String strValue = getValue(eleString,”string“);”这行代码不起作用。
//解析Plist并填写arraylist public ArrayList parsePlist(String xml){
final ArrayList<DataModel> dataModels = new ArrayList<DataModel>();
//Get the xml string from assets
final Document doc = XMLfromString(xml);
final NodeList nodes_array = doc.getElementsByTagName("array");
//Fill in the list items from the XML document
for ( int index = 0; index < nodes_array.getLength(); index++ ) {
final Node node = nodes_array.item(index);
if ( node.getNodeType() == Node.ELEMENT_NODE ) {
final Element e = (Element)nodes_array.item(index);
final NodeList nodeKey = e.getElementsByTagName("key");
final NodeList nodeValue = e.getElementsByTagName("string");
DataModel model = new DataModel();
for (int i=0; i < nodeValue.getLength(); i++) {
final Element eleKey = (Element)nodeKey.item(i);
final Element eleString = (Element)nodeValue.item(i);
if ( eleString != null ) {
String strValue = getValue(eleString, "string");
if(getValue(eleKey, "key").equals("Title")) {
model = new DataModel();
model.setTitle(strValue);
} else if(getValue(eleKey, "key").equals("File Name")) {
model.setFName(strValue);
dataModels.add(model);
}
}
}
}
}
return dataModels;
}
请帮我解决这个问题。我正在使用网上提供的示例,链接为http://androidquery.blogspot.in/2012/04/plist-parsing.html