java - Is there a JAXB annotation to do this? -


im using jaxb serialize java model, in jaxb can choose between @xmlelement or @xmlattribute

my model looks like:

public class link {     string rel;     string href; } 

if annotate properties in link class @xmlattribute link like

<link rel="self" href="http://mycompany.com/resource?param=blah" /> 

if annotate properties @xmlelement link like:

<link>     <rel>self</rel>     <href>http://mycompany.com/resource?param=blah</href> </link> 

i have requirement make xml this, sort of mix, don't want href tags around url using @xmlelement href won't work:

<link rel="self">http://mycompany.com/resource?param=blah</link> 

is there way using jaxb?

you can use @xmlvalue use case.

@xmlaccessortype(xmlaccesstype.field) public class link {      @xmlattribute     string rel;      @xmlvalue     string href;  } 

for more information


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -