How can I use a regular expression to parse XML?
Let's suppose we have the following:
$string = '<z>1a<z>2b</z>3c<z>4d</z>5e</z>';
preg_match_all('/<z>(.+)<\/z>/', $string, $result_a);
preg_match_all('/<z>(.+)<\/z>/U', $string, $result_b);
preg_match_all($regex, $string, $result_x);
If I run that, then $result_a will have the string (among the items of the array):
'1a<z>2b</z>3c<z>4d</z>5e'
In addition, variable $result_b will have the strings (among the items of the array):
'1a<z>2b'
'4d'
Now, I want $result_x to have '2b' and '4d' separately, among the items of the array.
What should $regex look like?
Thanks in advance!!!