Reading XML string from database and parse using Jquery

SubVert

New Member
Here is a piece of jquery code from my html page\[code\]$.ajax({ url: 'userlist.php', type: 'post', data: 'id='+extr, success: function(results){ $("#uservidshow").text("Page Title: "+$(results).find("vidlist").attr("title")); //$("#uservidshow").text(results); $(results).find("vids").each(function(){ $("#uservidshow").append("<br/><br/>Video Name: "+$(this).attr("vtitle")+"<br/>Link: "+$(this).attr("link")+"<br/>Description: "+$(this).find("descr").text()+"<br/><br/>"); }); } }); \[/code\]--- Here is the output that gets displayed in div#uservidshow --- \[quote\] Page Title: undefined Video Name: Kids video Link: http://www.youtube.com/watch?v=PIchX1LX0 Description:\[/quote\]My question is:
  • Why do I get 'undefined' page title?
  • Why do i get a blank under the description?
--- Here is a piece of code from userlist.php --- \[code\]<?php$getid=$_POST['id']; ....[few lines of code].... $pickfrmtab= mysql_query("SELECT * FROM mytable WHERE userid='$getid'"); if(mysql_num_rows($pickfrmtab)==1){ while($row = mysql_fetch_array($pickfrmtab)){ echo htmlspecialchars_decode($row['pagecontent'], ENT_QUOTES); //'pagecontent' contains my xml string } }else{ echo "Unable to get PLAYLIST"; } ?>\[/code\]--- Here is the XML string that is stored in database under the column name 'pagecontent'---\[code\]<?xml version='1.0' encoding='UTF-8' ?><vidlist title='My Fav Videos'><vids link='http://www.youtube.com/watch?v=PIchX1LX0' vtitle='Kids video'><descr><![CDATA[this is nice]]></descr></vids><comment allow='no'></comment></vidlist>\[/code\]As you might have guessed, i have applied htmlspecialchars() to the actual xml string before inserting it into database\[code\]$xmldata="http://stackoverflow.com/questions/12760622/<?xml version='1.0' encoding='UTF-8' ?>".$_POST['actualxmlstrng']; $xmldata_safe=htmlspecialchars($xmldata, ENT_QUOTES);//inserted $xmldata_safe into the datacbase field 'pagecontent' SUCCESSFULLY\[/code\]Just to give you an idea, this is what $xmldata looks like before applying htmlspecialchars: \[code\]<?xml version='1.0' encoding='UTF-8' ?><vidlist title='My Fav Videos'><vids link='http://www.youtube.com/watch?v=PIchX1LX0' vtitle='Kids video'><descr><![CDATA[this is nice]]></descr></vids><comment allow='no'></comment></vidlist>\[/code\]
 
Back
Top