I need a regex or a function in PHP that will validate a string to be a good XML element name.
Form w3schools:
XML elements must follow these
This should give you roughly what you need [Assuming you are using Unicode]: (Note: This is completely untested.)
[^\p{P}xX0-9][^mMlL\s]{2}[\w\p{P}0-9-]
\p{P} is the syntax for Unicode Punctuation marks in PHP's regular expression syntax.