I'm way out of my coding depth and need desperate help.
Posted: Mon Jul 20, 2009 8:50 am
Hi there, someone please help. I've been trying to fix an xml feed for weeks and cannot seem to get past here.
The feed is generated by the following script, but I need it to read what's in the <div> tags that are on the site it pulls the info from. At the moment it just spits out this when you run it.
An invalid character was found in text content. Error processing resource 'http://www.**********.co.uk/rad.xml'. Line 1...
<description><div>
Here is the php file. PLEASE SOMEONE HELP ME SORT THIS OUT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>RAD Feed</title>
</head>
<body>
<?php
include "development/StripAttributes.php";
$username = "*********"; //Database Username
$password = "*********"; //Database Password
$hostname = "*********"; //Database Host
$dbname = "********"; //Database (or Catalog in MySQL parlance) name
$dbh = mysql_connect($hostname, $username, $password) or die("Could not connect to database server");
$selected = mysql_select_db($dbname, $dbh) or die("Database not found or problem connecting");
$result = mysql_query("SELECT position, postdate, jobref, jobid, country, description FROM jobs");
// if the file exists already, delete it first to flush data
$xmlfeedfile = "rad.xml";
$filehandle = fopen($xmlfeedfile, 'w');
$itemLink = $fullurl.'/info_jobid_'.$b[jobid].'.html';
$xmlString = '<'.'?'.'xml version="1.0" encoding="utf-8" '.'?' .'>
<source>
<publisher>******</publisher>
<publisherurl>*******</publisherurl>';
fwrite($filehandle, $xmlString);
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$xmlString = '<job>
<title>' . $row{position} . '</title>
<date>' . $row{postdate} . '</date>
<referencenumber>' . $row{jobref} . '</referencenumber>
<url><a href="http://www.******.co.uk' . $fullurl . '/info_jobid_' . $row{jobid} . '.html" target="job' . $row{jobid} . '">' . $row{jobref} . '</a></url>
<country>United Kingdom</country>
<description>' . $row{description} . '</description>
</job>
';
fwrite($filehandle, $xmlString);
}
mysql_close($dbh);
fwrite($filehandle, "</source>");
fclose($filehandle);
?>
</body>
</html>
The feed is generated by the following script, but I need it to read what's in the <div> tags that are on the site it pulls the info from. At the moment it just spits out this when you run it.
An invalid character was found in text content. Error processing resource 'http://www.**********.co.uk/rad.xml'. Line 1...
<description><div>
Here is the php file. PLEASE SOMEONE HELP ME SORT THIS OUT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>RAD Feed</title>
</head>
<body>
<?php
include "development/StripAttributes.php";
$username = "*********"; //Database Username
$password = "*********"; //Database Password
$hostname = "*********"; //Database Host
$dbname = "********"; //Database (or Catalog in MySQL parlance) name
$dbh = mysql_connect($hostname, $username, $password) or die("Could not connect to database server");
$selected = mysql_select_db($dbname, $dbh) or die("Database not found or problem connecting");
$result = mysql_query("SELECT position, postdate, jobref, jobid, country, description FROM jobs");
// if the file exists already, delete it first to flush data
$xmlfeedfile = "rad.xml";
$filehandle = fopen($xmlfeedfile, 'w');
$itemLink = $fullurl.'/info_jobid_'.$b[jobid].'.html';
$xmlString = '<'.'?'.'xml version="1.0" encoding="utf-8" '.'?' .'>
<source>
<publisher>******</publisher>
<publisherurl>*******</publisherurl>';
fwrite($filehandle, $xmlString);
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$xmlString = '<job>
<title>' . $row{position} . '</title>
<date>' . $row{postdate} . '</date>
<referencenumber>' . $row{jobref} . '</referencenumber>
<url><a href="http://www.******.co.uk' . $fullurl . '/info_jobid_' . $row{jobid} . '.html" target="job' . $row{jobid} . '">' . $row{jobref} . '</a></url>
<country>United Kingdom</country>
<description>' . $row{description} . '</description>
</job>
';
fwrite($filehandle, $xmlString);
}
mysql_close($dbh);
fwrite($filehandle, "</source>");
fclose($filehandle);
?>
</body>
</html>