java - Sample XML HashMap for SimpleXML -
using simplexml
lib android possible create hashmap out of these:
<items> <item> <id>1</id> <name>chicken</name> <amount>13</amount> </item> <item> <id>2</id> <name>potatoes</name> <amount>3</amount> </item> </items>
i want create hashmap contain id , item, this:
hashmap<integer, item>
where id id of item (the value itself). possible?
i tried creating item class holds id, name , amount:
class item { @element(name=id) public int id; @element(name="name") public string name; @element(name="amount") public int amount;
}
and created wrapper like
class items { @elementmap(@field="item", keytype=integer.class, valuetype=item.class) private map<integer, item> mitems = new hashmap<integer, item>(); // .. getters / setters
}
but fails find corresponding fields...
when use list instead of hashmap - works expected. need hashmap addition list field in items wrapper class.
any help?
is maybe might that:
how serialize map<string, string> using simple xml?
and
http://old.nabble.com/serializing-collections-with-both-simplexml-annotated-and-not-annotated-types-td19679788.html
it doesn't explicitly point integer,string hashmap show idea.
Comments
Post a Comment