|
|
|
$xmlDoc->load($xml); ทำไมมันถึง error ได้อ่ะครับ ทั้งที่เมื่อวานยังไม่เป็น |
|
|
|
|
|
|
|
Warning: DOMDocument::load() [domdocument.load]: Empty string supplied as input in C:\AppServ\www\rss\getrss.php on line 21
Code (PHP)
<?php
//get the q parameter from URL
$q=$_GET["q"];
//find out which feed was selected
if($q=="RSSIT")
{
$xml=("http://www.thairssfeed.com/xml/xml_news_0007.xml");
}
elseif($q=="RSSTHAI")
{
$xml=("http://www.rssthai.com/rss/lastest.xml");
}
elseif($q=="ARIP")
{
$xml=("http://www.arip.co.th/rss/rss_tips.xml");
}
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
//get elements from "<channel>"
$channel=$xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$channel_desc = $channel->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;
//output elements from "<channel>"
echo("<p><a href='" . $channel_link
. "'>" . $channel_title . "</a>");
echo("<br />");
echo($channel_desc . "</p>");
//get and output "<item>" elements
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<=2; $i++)
{
$objConnect = mysql_connect("localhost","root","localhost") or die("Error Connect to Database");
$objDB = mysql_select_db("localhost");
mysql_query("SET NAMES UTF8");
$strSQL = "INSERT INTO category ";
$x1=$channel_title;
$x2=$item_title;
$x3=$item_link;
$x4=$item_desc;
$x5=$item_date;
$strSQL .="VALUES ";
$strSQL .="('".""."','".$x1."','".$x2."' ";
$strSQL .=",'".$x3."','".$x4."','".$x5."','"."','"."','"."') ";
$objQuery = mysql_query($strSQL);
echo ("<p><a href='" . $item_link
. "'>" . $channel_title . "</a>");
$item_title=$x->item($i)->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$item_link=$x->item($i)->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$item_desc=$x->item($i)->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;
$item_date=$x->item($i)->getElementsByTagName('pubDate')
->item(0)->childNodes->item(0)->nodeValue;
echo ("<p><a href='" . $item_link
. "'>" . $item_title . "</a>");
echo ("<br />");
echo ($item_date . "</p>");
echo ("<br />");
echo ($item_desc . "</p>");
}
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-11-05 12:20:08 |
By :
isolate |
View :
1103 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$xmlDoc->load($xml); $xml มีค่าเท่ากับไม่มีค่า(null) ครับ เลยแสดง warning อย่างที่เห็นนะแหล่ะครับ
เช็ค $_GET["q"] ว่าค่าที่ได้ตรงกับเงื่อนไข if-else ข้างบนหรือเปล่าครับ
echo $_GET["q"];
echo $xml;
|
|
|
|
|
Date :
2009-11-05 12:34:51 |
By :
xbeginner01 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|