How to check if the content (string) in a node is in the header?

I want to check if the contents of the node file in the XML file is in the header or not. I know that there is a TextInfo.ToTitleCase method that converts any string to a header, but is there something like TextInfo.IsTitleCase that basically checks the string, whether it is in the header or not?

For example, I have several XML files, each of which has a node <title>in one of the following formats (or, perhaps, in some other formats, you get an idea)

<title>Confer<title>
<title>CONFER<title>
<title>confer<title>
<title>cOnFEr<title>
<title>confeR<title>

The program should check the contents of the nodes <title>, and if it is not in the header, as for all the above examples, except the first, it should write a message saying something like "File: xyz..xml ==> Line 100: <title>cOnFEr<title>should be in the title"

How can I do this efficiently?

+4
source share
1 answer
bool IsTitleCase(string text)
{
    if (string.IsNullOrEmpty(text))
        return false;
    return text == CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text);
}
+2
source

Source: https://habr.com/ru/post/1696168/


All Articles