Location: PHPKode > scripts > Breadcrumbs navigation with PHP 5, SimpleXML, XPath and class > breadcrumbs-navigation-with-php-5-simplexml-xpath-and-class/class/xml.breadcrumb.class.php
<?php
class XMLBreadcrumb
{
	function PrepareBreadcrumb($url, $txt, $navid, $path, $matching1, $matching2, $pmain)
	{

	 // Url of main page
	$url = "http://claudio:8080/phpPublikationen/Breadcrumbs/Home_Breadcrumb.php";
	
	 // name of the main page
  	$txt = "Homepage";  	
  	
  	// name of the id to pick up to the correct page
  	$navid = 'pageid';
  	
  	// path to the XML file
  	$path = "../xml/navibreadcrumb.xml";
  	
  	// path to the XML node with the link
  	$pmain = "/links/link";
  	
  	// path to the XML child node with the text for the Url
  	$matching1 = "//uritext";
  	
  	// path to the XML child node with the Url
  	$matching2 = "//urltext";	
  	

	$xml = simplexml_load_file($path);	
	$id = $_GET[$navid];	
	$pathmain = $pmain;
	
	if(!isset($_GET[$navid]))
		{
			$res = $xml->xpath($pathmain);
			echo "<table width='100' border='1' cellspacing='2' cellpadding='0'>
			<tr><td><a href=$url>$txt <<</a></td></tr>";	
			for ($x=0; $x < sizeof($res); $x++)
			{
					$uri	= $res[$x]->uritext;
					$url	= $res[$x]->urltext;
					$a	= $res[$x]->attributes();
					echo "<tr><td nowrap>&nbsp;->&nbsp;<a href=$url?pageid=$a>$uri</a></td></tr>";
			}
			echo "</table><br/>";	
		}
		
	if(isset($_GET[$navid]))
	{		
		if ($res = $xml->xpath($pathmain))
		{
			echo "<table width='200' border='1' cellspacing='2' cellpadding='0'><tr>
			<td nowrap><a href=$url>$txt <<</a></td>";
			for ($x=0; $x < $id; $x++)
			{				
				foreach($xml->link[$x]->attributes() as $a => $b)
				{
					if($b != $id)
					{
						$uri = $res[$x]->uritext;
						$url = $res[$x]->urltext;
						echo "<td nowrap>&nbsp;->&nbsp;<a href=$url?pageid=$b>$uri</a></td>";
					}
					else
					{
						$uri = $res[$x]->uritext;
						echo "<td nowrap>&nbsp;>>&nbsp;<i>$uri</i></td>";
					}	
				}
			}
			echo "</tr></table><br/>";
		}				
	}
   }
}
?>		
Return current item: Breadcrumbs navigation with PHP 5, SimpleXML, XPath and class