title: XStream fromXML() exception
body: <p>I am trying to deserialize a string in Java using the XStream package. The XStream package can serialize my class fine. I get the XML (cannot change format of XML) from a server and try to save its node information to the corresponding variables in a certain class. My function is at the bottom and I tried to register a new converter for the XStream object (thinking that it was because one variable is a byte array) but still no luck. Can anyone shed some light on these exceptions? Do i need to register "MyClass" and write my own converter for XStream to handle deserializing my class? Thanks in advance.</p>
  
  <p>Exception if a string or StringReader object are passed into fromXML() as input:</p>
  
  <blockquote>
    <p>[Fatal Error] :1:1: Content is not allowed in prolog.<br>
    com.thoughtworks.xstream.io.StreamException:  : Content is not allowed in prolog.<br>
        at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:86)<br>
        at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:66)<br>
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:853)  </p>
  </blockquote>
  
  <p>Exception if ByteArrayInputStream is used as input to fromXML():</p>
  
  <blockquote>
    <p>com.thoughtworks.xstream.converters.ConversionException: ByteSize : ByteSize : ByteSize : ByteSize<br>
    ---- Debugging information ----<br>
    message             : ByteSize : ByteSize<br>
    cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException<br>
    cause-message       : ByteSize : ByteSize<br>
    class               : MyClass<br>
    required-type       : MyClass<br>
    path                : /MyClass/ByteSize<br>
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:89)<br>
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)<br>
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)<br>
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60)<br>
        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:137)<br>
        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)<br>
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:923)<br>
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:909)<br>
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:861)  </p>
  </blockquote>
  
  <pre><code>static Object fromXmlString(String xml) 
  {
      XStream xStream = new XStream(new DomDriver());
      xStream.registerConverter(new EncodedByteArrayConverter());
      //tried all 3 below
      //return xStream.fromXML(new StringReader(xml));
      //return xStream.fromXML(new ByteArrayInputStream(xml.getBytes()));
      return xStream.fromXML(xml);
  }
  </code></pre>