How would you find the value of string that is repeated and the data between it using regexes? For example, take this piece of XML:
<tagName>Data between the tag</tagName>
What would be the correct regex to find these values? (Note that tagName
could be anything).
I have found a way that works that involves finding all the tagName
s that are inbetween a set of < >
and then searching for the first instance of the tagName
from the opening tag to the end of the string and then finding the closing </tagName>
and working out the data from between them. However, this is extremely inefficient and complex. There must be an easier way!
EDIT: Please don't tell me to use XMLReader; I doubt I will ever use my custom class for reading XML, I am trying to learn the best way to do it (and the wrong ways) through attempting to make my own.
Thanks in advance.