SimpleXML Help needed (reading and displaying)

Hello all, and thanks in advance for reading,

I have the following XML File:

<ruleset>
	<rule id="10">
	<name>Campaign 1</name>
		<match>
			<keyword>123</keyword>
			<keyword>car</keyword>
		</match>
		<results>
			<result>
				<title><![CDATA[Some cutom <b>title</b>]]></title>
				<body><![CDATA[This is result <b>body</b>! bla bla bla bla bla bla bla bla bla bla]]></body>
				<visibleurl><![CDATA[www.<b>ukr.net</b>]]></visibleurl>
				<clickurl>http://www.ukr.net/</clickurl>
			</result>
			<result>
				<title><![CDATA[Second <b>title</b>]]></title>
				<body><![CDATA[This is second body. Here could be your advertising!]]></body>
				<visibleurl><![CDATA[www.<b>ukr.net</b>]]></visibleurl>
				<clickurl>http://www.ukr.net/</clickurl>
			</result>
		</results>
	</rule>
	
	<rule id="77">
	<name>Campaign 2</name>
		<match>
			<keyword>abc</keyword>
			<keyword>qwe</keyword>
		</match>
		<results>
			<result>
				<title><![CDATA[Third title]]></title>
				<body><![CDATA[A title is a prefix or suffix added to someone's name to signify either veneration, an official position or a professional or academic qualification. <b>...</b>]]></body>
				<visibleurl><![CDATA[www.<b>ya.net</b>]]></visibleurl>
				<clickurl>http://www.ya.ru/</clickurl>
			</result>
		</results>
	</rule>
	
</ruleset>

And i am looking to read through it. I want to loop through the <rule id=“”> trees, and load the data in each of them in an array.

Sofar i have this:

$filename = $_SERVER['DOCUMENT_ROOT']."/users/".$_SESSION[request::authHash()]['id']."/serp.xml";
		$handle = fopen($filename,'r+') or die("Cannot open file");
		$contents = fread($handle, filesize($filename));
		fclose($handle);
		$xml = new SimpleXMLElement($contents);


		$data = array();
		
		foreach ($xml->xpath('rule') as $v) {
			
  


		
			array_push($data, array(
				'id' => $v->rule,
				'name' => $v->name
			));
		} 
		
		$this->tpl->assign('data', $data);
		
		$this->tpl->display('admin_serp.tpl');
	}

Ive got the names being pushed perfectly now, but i want the <rule id=“”> to be read and be passed in the id field, how do i do that?

Regards

Please post your answer so that others can learn from your experience. (:

i reedited my code, now i got a new problem, whats up there works but doesnt do exactly what i want yet

Would you like any help with it?