0

I am trying to convert XML into java.util.map in order to achieve this I am using XStream API but while converting I encountered an exception as follows:

com.thoughtworks.xstream.mapper.CannotResolveClassException: root

Here is my XML Sample:

<?xml version='1.0' encoding="UTF-8"?>
    <root>
    <mobile>
        <id>m0001</id>
        <manufacture>NOKIA</manufacture>
        <model>N90</model>
        <touchscreen>Yes</touchscreen>
        <keyboard>Yes</keyboard>
        <quantity>25</quantity>
        <price>RM 2200</price>
    </mobile>
    </root>

and here is my code:

public Map<String, Object> convertXml(File xmlFile) {
        XStream xStream = new XStream(new DomDriver());
        Map<String, Object> xmlMap = (Map<String, Object>) xStream.fromXML(xmlfile);
        return xmlMap;
    }
Talha Bin Shakir
  • 2,563
  • 10
  • 38
  • 54
  • Possible duplicate of [post][1] [1]: http://stackoverflow.com/questions/25085399/converting-xml-into-java-mapstring-integer/25085677#25085677 Hope that helps – Malatesh Aug 01 '14 at 17:37

1 Answers1

0

This may be an answer to your problem - http://www.digipedia.pl/usenet/thread/14051/1525/.

aretai
  • 1,619
  • 6
  • 19
  • 30