Hi I am trying to get the "level" from this page I use this code: <?php $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, "http://www.wowarmory.com/character-sheet.xml?r=Garona&cn=Bob"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($curl); curl_close ($curl); if(preg_match('/<character.{1,30} charUrl="r=Garona&cn=Bob".{1,300}level="(\d+)"/s', $result, $match)) { $level=$match[1]; echo "level is $level "; } else echo "attemp 1 failed "; if(preg_match('/<div id="leveltext">"(\d+)"/s' , $result, $match)) { $level=$match[1]; echo "level is $level "; } else echo "attemp 2 failed $result"; ?> PHP: I have put the code here: http://tinyurl.com/y49sg5x If you go to the original page, you'll see the following in source code (what I am trying to get in attemp 1) <character battleGroup="Rampage" charUrl="r=Garona&cn=Bob" some more stuff (less than 300 chars) level="80" Code (markup): and if you look at the source code of my page, where I echo $result, you'll see this code: (what I am trying to get in attemp 2) <div id="leveltext">80</div> Code (markup): But I don't know why it fails when I try to get the information Any help would be extremely appreciated Thanks in advance
Depending on your host you may need to get Curl enabled, Hostgator have it disabled by default. Thanks Brian
if(preg_match('/<div id="leveltext">"(\d+)"/s' , $result, $match)) Yep ... i don't know why you push some extra " to preg_match ... lol