Please, consider an XML document containing these fields:
...
<example>An example</example>
<project>A project</project>
<projectName>A project name</projectName>
<projectDate>A project date</projectDate>
...
To pick up one, this code suffices:
Cases[dataXML, XMLElement["project", __, __], Infinity]
But what if I need all fields whose name starts with "project" ?
None of these is appropriate:
Cases[dataXML, XMLElement["project" ~~ _, __, __], Infinity]
Cases[dataXML, XMLElement["project" ~~ __, __, __], Infinity]
Cases[dataXML, XMLElement["project" ~~ ___, __, __], Infinity]
and, similarly for regular expressions, too.
An obvious, although a bit deceptive, escamotage is:
data = ToString @ dataXML;
ptr = Shortest @ RegularExpression["XMLElement\\[project[^\\]]*\\]"];
StringCases[data, ptr]
nevertheless, I would like to understand the motives of the former failure and if it teaches a broader lesson. Bye !