XML element with attribute has ":" in JAXB

I am having a problem when I get the attributes of an xml file. These attributes are written as follows:

@XmlAttribute(name="xml:lang")

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

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

Thanks.

+6
source share
1 answer

xml explicitly a namespace prefix . You can try to specify a namespace:

 @XmlAttribute(name = "lang", namespace = javax.xml.XMLConstants.XML_NS_URI) 
+8
source

Source: https://habr.com/ru/post/981443/


All Articles