I am trying to search through html tags with PHP and I cannot seem to get the regex correct, I am not sure what I am doing wrong. Here is the pattern I am trying to search through:
<cas:serviceResponse xmlns:cas='somesite.edu'> <cas:authenticationSuccess> <cas:user>user29</cas:user> </cas:authenticationSuccess> </cas:serviceResponse>
I used $resp = htmlentities(file_get_contents($url)); and the above prints out if I echo $resp. I am trying to use preg_match to search in cas:user to extract the username , user29.
Here is the regex pattern I am trying to use:
preg_match("'<cas:user>(.*?)</cas:user>'", $resp, $match);
But it doesn't seem to work when I echo $match. What am I doing wrong?