0
XML的XML序列化的對象(哈希映射): (DE)從這種形式的使用XStream
JAVA的Hashmap: 地圖= {鍵1 =文本1,鍵2 =文本2}
此不起作用。爲什麼?
String xml = "<nodes><node id=\"key1\"><![CDATA[text1]]></node><node id="\key2\"><![CDATA[text2]]></node></nodes>";
XStream xs = new XStream();
xs.alias("nodes", Map.class);
xs.alias("node", String.class);
xs.useAttributeFor("id",String.class);
Map<String,String> map= (Map<String,String>) xs.fromXML(xml);
System.out.println(map);