Is there a standard for the maximum number of characters allowed in an XML attribute?
I tried researching W3C consortium and couldn't find anything on the character limit aside from some notes on escaping special characters.
Attribute Types: There are three types of attributes described below: String types Attribute: This type of attribute takes any string literal as a value.
attributes cannot contain multiple values (elements can) attributes cannot contain tree structures (elements can) attributes are not easily expandable (for future changes)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With