java - JAXB to unmarshall <string>foobar</string> -


Greetings! I'm returning a server to my client who looks like this:

  & lt; String xmlns = "..." & gt; Foobar & lt; / String & gt;  

I'm new to JACAB and a lot of things are working out. I thought it would be very easy for the Marshall and would be unrelated to the string and for this. It took a while, but I finally figured out how to do it martial

  public static string toxml (strings) throws an exception (Jxbctx reference = JxBCTX.New instance (string class) ; Marshaller Marshaller = Ref. Cretemriter SW; new stringwriter (); Marshaller.marshal (new JAXBElement (new QN ("", "string"), string class, S), SG; return sw.toString ();}  

So my question is, how did I provoke it? It can not be annotated as a root element. I want to create a new example of JAXBContext Can not use java.lang in the form (I get an ObjectFactory missing exception).

Is anyone giving the knowledge? It can not be so difficult, right?

You must write an object model that is your XML structure, and to dissatisfied with it Esiabi tell.

  @XmlRootElement (name = "string", namespace = "blah"), for example) public class Maistring {@XmlValue string value; ) JAXBContext References = JAXBContext.newInstance (MyString.class); Mystring MyStrig = (Mystring) Reference. CreteUnnerSeller (). Unmanned (...);  

This XML and string xmlns = "blah" & gt; Foobar & lt; / String & gt; Replace namespace accordingly. If you have many namespaces, JAXB is not really a tool for you.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -