Hi.

After some time looking for the way to check the presence of links in a sitemap to add specific css styling in the head of my site, I have this script that works perfectly:

Code:
<?php
$DomDocument = new DOMDocument();
$DomDocument->preserveWhiteSpace = false;
$DomDocument->load('http://www. the web site .com/index.php?option=com_xmap&view=xml&tmpl=component&id=1');
$DomNodeList = $DomDocument->getElementsByTagName('loc');

foreach($DomNodeList as $url) {
$urls[] = $url->nodeValue;
}
if(in_array("http://www. the web site .com/link-a",$urls)){
$css= '<link href="/css/link-a.css" rel="stylesheet" type="text/css" />';
}
echo $css;
?>
It looks for tag names in the loc tags of a sitemap to provide an array, offering the possibility to add a css for a given link.

The problem is that when I add more that two conditionals the script inserts just the first and the last one.

In this case, with five elements, just link-a.css and link-e.css appear in the head tag.

Code:
<?php
$DomDocument = new DOMDocument();
$DomDocument->preserveWhiteSpace = false;
$DomDocument->load('http://www. the website .com/index.php?option=com_xmap&view=xml&tmpl=component&id=1');
$DomNodeList = $DomDocument->getElementsByTagName('loc');

foreach($DomNodeList as $url) {
$urls[] = $url->nodeValue;
}
if(in_array("http://www. the web site .com/link-a",$urls)){
$css= '<link href="/css/link-a.css" rel="stylesheet" type="text/css" />';
}
if(in_array("http://www. the web site .com/link-b",$urls)){
$css= '<link href="/css/link-b.css" rel="stylesheet" type="text/css" />';
}
if(in_array("http://www. the web site .com/link-c",$urls)){
$css= '<link href="/css/link-c.css" rel="stylesheet" type="text/css" />';
}
if(in_array("http://www. the web site .com/link-d",$urls)){
$css= '<link href="/css/link-d.css" rel="stylesheet" type="text/css" />';
}
if(in_array("http://www. the web site .com/link-e",$urls)){
$css= '<link href="/css/link-e.css" rel="stylesheet" type="text/css" />';
}
echo $css;
?>
Well, my level is basic, and I would appreciate some advice on the problem, and a suitable way to gather those elements in a single script, since there are some scores of them in my project.

Thanks very much.