<?php
$ch = curl_init("http://xxxxxx.xxxx/hhhhhh/kkkkk.htm");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
$html = curl_exec($ch);
curl_close($ch);
#CREATE DOM PARSER
$xml = new DOMDocument("1.0");
$root = $xml->createElement("programme");
$book = $xml->createElement("tvprogram");
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$dom->formatOutput = true;
$dom->preserveWhiteSpace = true;
$images= $dom->getElementsByTagName('img');
foreach($images as $img){
$icon= $img ->getAttribute('src');
if( preg_match('/\.(jpg|jpeg|gif)(?:[\?\#].*)?$/i', $icon) ) { //only matching types
}
[b]$path_parts = pathinfo($icon);
$programname=$path_parts['filename'];[/b]
$xml->appendChild($root);
#$title = $xml->createElement("Channel"); //CHANNEL NAME
$id = $xml->createElement("imageurl"); //CHANNEL IMAGE
$showname= $xml->createElement("programname"); //PROGRAM NAME
#$showtime= $xml->createElement("programtime"); //PROGRAM TIME
#$descriptime= $xml->createElement("description"); //PROGRAM DESCRIPTION
#$titleText = $xml->createTextNode($channel);
$idText= $xml->createtextNode($icon);
[b]$shownameText= $xml->createTextNode($programname->nodeValue);[/b]
#$showtimeText= $xml->createTextNode($programtime->nodeValue);
#$showdescripText= $xml->createTextNode($descrip->nodeValue);
#$title->appendChild($titleText);
$id->appendChild($idText);
$showname->appendChild($shownameText);
#$showtime->appendChild($showtimeText);
#$descriptime->appendchild($showdescripText);
#$book->appendChild($title);
$book->appendChild($id);
$book->appendchild($showname);
#$book->appendchild($showtime);
#$book->appendchild($descriptime);
$root->appendChild($book);
$xml->formatOutput = true;
$xml->save("horror.xml") or die("Error");
}
?>
Should be fairly simple, just wanting to extract the filename from the http url that I am pulling the img from. I have other elements # , I am not interested in those at this time for this particular project. Thanks for looking