XML DOM PARSER


</pre>
<?php

*/ $url = 'urlname';
 $ch = curl_init();
 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // setting option for url retrival
 curl_setopt ($ch, CURLOPT_URL, $url);
 curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
 curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
 curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
 $raw_data = curl_exec ($ch);
 curl_close ($ch);
 $xml = simplexml_load_string($raw_data); // loads xml content
 for($i=0; $i<1;$i++) {
 $data = $xml->channel->item[$i]; // for counting each item content from server
 $name = $data->title;
 $link = $data->link;
 $description = $data->description;
 $content = $data->content;
 ?>
<!-- <div class='blog_link'><a href='<?php echo $link; ?>'><?php echo $name; ?></a></div>-->
<?php echo "<div class='blog_description'>".$description.$content."</div>";?>
 <div class='blog_more'><a href='<?php echo $link; ?>'>Read More</a></div>
<?php } ?>
<pre>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s