Java – how do I check if a string is a valid XML element name?
•
Java
You know the functions in Java, which will verify that a string is a good XML element name
Form W3Schools:
I found that other problems that provide regular expression solutions already have such a function?
Solution
If you use Xerces XML parser, you can use xmlchar (or xml11char) class isvalidname () method, as follows:
org.apache.xerces.util.XMLChar.isValidName(String name)
There is also an example code of isvalidname available here
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码