Jump to content

Parsing XML with pregmatch


residual

Recommended Posts

<?php 
	$h3tag = $_GET['h3tag']; 
	if	(empty($h3tag))	{
		$h3tag = 'blank';
	}

	$h3tag = str_replace(" ","%20",$h3tag);

	$ch = curl_init();
	$timeout = 5;
	curl_setopt ($ch, CURLOPT_URL, 'http://duncanmackenzie.net/services/GetXboxInfo.aspx?GamerTag='. $h3tag);
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	$in1 = curl_exec($ch);
	curl_close($ch);

	preg_match('#<Info>(.+?)</Info>#',$in1, $online1);
	preg_match('#<Info2>(.+?)</Info2>#',$in1, $status1);

	$online = $online1[1];
	$status = $status1[1];

	$output = '<div> Online Status: ' . $online . '</div><div> Status: ' . $status . '</div>';
	echo $output;
?>

 

This works fine for $online but not for $status.  Please anyone any ideas?  ???

Link to comment
https://forums.phpfreaks.com/topic/76085-parsing-xml-with-pregmatch/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.