how to unmarshal a xml file(plist) generated from iOS with xstream in android

matrix00

New Member
while I unmarshal a plist in android, I've several questions :a plist's structure is something like this \[code\]<?xml...><!doctype...><plist><dict> <key>attribute1</key> <string>value</string> ...</dict></plist>\[/code\]My first question: how can I remove the header of xml and plist ? I've a com.thoughtworks.xstream.mapper.CannotResolveClassException:plist exception, but I'm quite sure that I've nothing before "< ?xml "Second one is that how can I remove the "alias" of xstream ? For the moment I cheat as I code xstream.alias("dict", CategoryIC.class);But I want to do it more correctly.My biggest question is that how can I read these nodes 2 by 2 ? As plist records my attributes with two lines, I don't know how to get the next node once I come across the line ...my unmarshal function :public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { Cat cat = new Cat(); if(reader.getNodeName().equals("plist")){ reader.moveDown(); if(reader.getNodeName().equals("dict")) while(reader.hasMoreChildren()){ reader.moveDown(); String attributeName; if(reader.getNodeName().equals("key")){ attributeName = reader.getValue(); reader.moveUp(); reader.moveDown(); if(attributeName.equals("BACKGROUND")) cat.setBackgroud(reader.getValue()); else i... } reader.moveUp(); } } return cat; }
 
Back
Top