Robert H
Robert H

Reputation: 11730

Does Java have an equivalent to C#'s XML attributes?

Consider this C# code:

[XmlRoot("RootElementName")]
public class GetReportStatusResponse
{
    ....
}

This code allows me to express this class as <RootElementName> rather then <GetReportStatusResponse> when serialized to XML.

Does Java have an equivalent?

Upvotes: 1

Views: 92

Answers (2)

someone
someone

Reputation: 6572

You can check JAXB here and it will support you

Upvotes: 1

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340763

Yes, it's called :

@XmlRootElement(name="RootElementName")
public class GetReportStatusResponse {
  //...
}

Upvotes: 3

Related Questions