Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML element with attribute has ":" in JAXB

Tags:

java

xml

jaxb

I have a problem when I am getting the attributes of a xml file. These attributes are written like this:

@XmlAttribute(name="xml:lang")

With @XmlAttribute I get attributes that they are written on a one word. If I leave this annotation @XmlAttribute(name="xml:lang") I get null

How can I get attribute's value of "xml:lang"?

Thanks.

like image 946
Celer Avatar asked Jan 23 '15 12:01

Celer


Video Answer


1 Answers

xml is clearly a namespace prefix. You can try stating the namespace it with:

@XmlAttribute(name = "lang", 
              namespace = javax.xml.XMLConstants.XML_NS_URI)
like image 120
Konstantin Yovkov Avatar answered Oct 11 '22 17:10

Konstantin Yovkov