TOMMY WANG
TOMMY WANG

Reputation: 1402

C# validate XML document case insenstive

Using xmlreader to validate an xml is always case senstive, is it possible to have a case insensetive validation? i.e. if the element name in the schema is 'FirstName', the xml with name 'Firstname' should be validated.

Upvotes: 0

Views: 839

Answers (2)

seekerOfKnowledge
seekerOfKnowledge

Reputation: 524

As you may have noticed, XML is case sensitive. So one way to make the validation case insensitive would be to make the schema case insensitive. In the schema, instead of FirstName, try using a pattern with the following: [Ff][Ii][Rr][Ss][Tt][Nn][Aa][Mm][Ee].

Upvotes: 0

Alexei Levenkov
Alexei Levenkov

Reputation: 100575

Xml is case sensitive language, so it will not be truly XML validation...

The easiest would be to read all text as text, convert to upper case and than load resulting string as XML.

Another option is to implement your own TextReader-based class (wrapping basic TextReader) and upper-case all letters. Would work much better for large XML documents.

Upvotes: 1

Related Questions