TheTVDB.com

Online TV Database
It is currently Tue Jul 29, 2014 3:50 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: XML parsing
PostPosted: Tue May 08, 2012 11:33 am 
Offline

Joined: Tue May 08, 2012 11:21 am
Posts: 1
Hi,

I am currently trying to parse the XML returned from the getSeries.php, but the parsing won't work as I want it to.

Currently I am getting the XML with cURL

Code:
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, "$mirrorpath/api/GetSeries.php?seriesname=$show_name");


and parse it with SAX

Code:
$parser=xml_parser_create();
xml_set_element_handler($parser, "openingTag","closingTag");
xml_set_character_data_handler($parser, "foundText");
xml_parse($parser,$xml);
xml_parser_free($parser);


function openingTag($parser,$tag,$attributes)
{
    global $currentTag;
    $currentTag = strtolower($tag);
}

function closingTag($parser,$tag)
{
    global $currentTag;
    $currentTag = null;
}

function foundText($parser,$characters)
{
    global $data, $currentTag;
    $data[$currentTag][] = $characters;
}



But when I want to echo the results I always get mistakes when it comes to & and '.
When there is a & in the title it is seen as a new show and ' is changed to some other symbols
and also lets the parser think it is a new show.

Code:
echo "<table>";
for($count=0; $count < count($data["seriesid"]); $count++)
{
    echo "<tr>";
   echo "<td>" . $data["seriesname"][$count] . "</td>";
   echo "<td class='input'>" . $data["seriesid"][$count] . "</td>";
   echo "</tr>";
   echo "<tr>";
   
}
echo "</table>";


Does anyone have a solution for this problem?
Like letting the parser completely ignore what is between the tags.
I tried replacing &amp; with "and", but this doesn't really solve the problem for other characters.

Thanks in advance
whw


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group