Updated: 02/10/2009

Breadcrumbs navigation with PHP 5, SimpleXML, XPath and class

Navigate through a website can be most irritating if the user is not well informed where he is and where he comes from. To prevent users from being lost the breadcrumbs method is one of the most suitable. SimpleXML, XPath and PHP 5 are perfect tools to create serious breadcrumbs positioning. This class is taking care of the breadcrumbs handling. The XML file contains all the necessary data to control standard and breadcrumbs navigation. The script controls seven parameters you deliver according to your environment and XML file by adapting the PHP code in the HTML file. The class is made of two parts: In the first part it loops through the XML file and sets text, Url and Id (which has to start with 1 and needs to be unique and incremental). In the second part we use a different technique to present the XML data (thanks to HTML table): First we read the id and set the corresponding elements (for example if id is 2 we show only the homepage, plus the first and the second link).