What is the max number of characters allowed in an XML attribute? What is the max number of characters allowed in an XML attribute? xml xml

What is the max number of characters allowed in an XML attribute?


I don't believe there is a character limit per the XML specification, but the Best Practice is to keep attribute values short.

If an attribute value grows long...chances are that it should be an element of its own rather than an attribute on another element.


There is no maximum character length for an attribute.

The spot where you could run into issues is the point where you are reading the xml file using another language.

The language you use to manipulate the xml file will determine your limitations.

For instance, if you plan on reading the information into a String, you should limit yourself to the maximum number of characters that can be held in a string in the language you are using.

Additionally, as others have said, you are probably not following standard name conventions if this is a problem. I would suggest that, if you have a large amount of text to store, it should be the value of an element, not an attribute.


I don't think there are standard limitations, but any particular implementation may be limited in its capabilities, so I'd try to keep the size sane.