Thursday, November 22, 2007

Tricks and tip in ..htaccess. .. (php)

1) Create Our own Error Code display page.. like "404 pagenot found"

For example, if you want a web page called 404.html to replace the default error page, put the following line in your .htaccess file:

ErrorDocument 404 /404.html

You can do the same with other error codes. make sure ur mentioned file are having in your root folder.

error document in apache see the link http://httpd.apache.org/docs/1.3/mod/core.html#errordocument

2) coming soon...

Tuesday, November 20, 2007

Xml Parsing..

XML INVOKING....
To get the xml from the feed...
function :
//call the function ..

getXml("www.dwmu/feedxml/");

function getxml($url)
{
$ch = curl_init(); // Initialize the curl session..

curl_setopt($ch,CURLOPT_URL,$url);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

$xmlval = curl_exec ($ch);

curl_close ($ch);

return $xmlval ; // now the full xml is return here ....

}
?>



Sample Xml structure..
================


How to parse the xml...? (above sample ) and get the valuse for the particular jobid .

$xmlobj = -->now consider the full xml is in the is ($xmlobj)variable . now ready to parse.

step1:
pass this xml and jobid into one function as ur own ..

parsexml($xmlobj,$id); //call the function

step2:
write a function to pars the xml

function parsexml($xmlobj,$id){
$xml = new SimpleXMLElement($xmlobj);

// damu get the "" for particular job id.............s...
$i=0;
foreach($xml->job as $listing){
if($xml->job[$i]->attributes() == $id){
$name = $listing->name;
$description = $listing->description;
$rollupdeptname = $listing->dept_name;
$qualification = $listing->qualification;
$location = $listing->location;
$email = $listing->email;
$postdate = $listing->postdate;
break;
}
$i++;
}
$jobdeails = array($name,trim($description),$rollupdeptname,$qualification,$location,$email,$postdate);
return $jobdeails;
}

now the xml is parsed and save inside the
$jobdeails array.