javascript - <description> tag causes xml to stop parsing? -


can see problem code? application works until add these lines:

 var descriptionnode = item.getelementsbytagname("description")[0];  var description = descriptionnode.firstchild.data;  var item = { ...               ...              ...              ...              ...              description: description,              ...            }; 

and view page

var descriptionnode = document.createelement("td");                     descriptionnode.setattribute("class", "description");                     descriptionnode.appendchild(document.createtextnode(item["description"]));                     tr.appendchild(descriptionnode);  ... <th scope="col">description</th> 

and rss.xml file

<description>this description</description> 

full snippet:

<html>     <head>         <script type="text/javascript">             var items = []; // contains newest items             var unsorted = []; // contains items              function init() {                 if (!localstorage.updateinterval) {                     localstorage.updateinterval = 5;                 }                  if (!localstorage.types) {                     localstorage.types = "audio:true;art:true;literature:true;";                 }                  chrome.browseraction.setbadgebackgroundcolor({color:[255, 102, 0, 255]});                  settimeout(makerequest, 3000);             }              function makerequest() {                 var xmlhttp = new xmlhttprequest();                 xmlhttp.onreadystatechange = function() {                     if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {                         parseitems(xmlhttp.responsexml);                     }                 };                  xmlhttp.open("get", "http://url.com/rss.xml", true);                 xmlhttp.send(null);                  settimeout(makerequest, 1000 * 60 * localstorage.updateinterval);             }              function parseitems(data) {                 var items = data.getelementsbytagname("item");                  (var = 0; < items.length; i++) {                     var item = items[i];                      var datenode = item.getelementsbytagname("pubdate")[0];                     var date = formatdate(datenode.firstchild.data);                      var titlenode = item.getelementsbytagname("title")[0];                     var title = formattitle(titlenode.firstchild.data);                      var type = titlenode.firstchild.data.split("[")[1].split("]")[0];                      var linknode = item.getelementsbytagname("link")[0];                     var link = trimspaces(linknode.firstchild.data);                      var authornode = item.getelementsbytagname("author")[0];                     var author = authornode.firstchild.data;                      var descriptionnode = item.getelementsbytagname("description")[0];                     var description = descriptionnode.firstchild.data;                      var item = { date: date,                                      title: title,                                     featured: false,                                     type: type,                                      author: author,                                     description: description,                                     link: link };                      unsorted[i] = items;                 }                  processitems();             }  ... 

view

    <script type="text/javascript">         var items = [];         var background;          function init() {             background = chrome.extension.getbackgroundpage();             items = background.items;              createitemtable();         }          function createitemtable() {             var table = document.getelementbyid("item-table");             var tbody = document.createelement("tbody");              (x in items) {                 var item = items[x];                 var tr = document.createelement("tr");                  if (item["featured"]) {                     tr.setattribute("class", "featured");                     item["featured"] = false;                 }                  var datenode = document.createelement("td");                 datenode.setattribute("class", "date");                 datenode.appendchild(document.createtextnode(item["date"]));                 tr.appendchild(datenode);                  var titlenode = document.createelement("td");                 titlenode.setattribute("class", "title");                 titlenode.appendchild(document.createtextnode(item["title"]));                 tr.appendchild(titlenode);                  var typenode = document.createelement("td");                 typenode.setattribute("class", "type");                 typenode.appendchild(document.createtextnode(item["type"]));                 tr.appendchild(typenode);                  var authornode = document.createelement("td");                 authornode.setattribute("class", "author");                 authornode.appendchild(document.createtextnode(item["author"]));                 tr.appendchild(authornode);                  var descriptionnode = document.createelement("td");                 descriptionnode.setattribute("class", "description");                 descriptionnode.appendchild(document.createtextnode(item["description"]));                 tr.appendchild(descriptionnode);                  tbody.appendchild(tr);             }              table.appendchild(tbody);         }          function opentab(url) {             chrome.tabs.create({url: url});         }     </script> </head> <body onload="init();" onunload="background.updatebadge();">     <img src="img/logo_popup.png" id="logo" alt="" title="" onclick="opentab('http://www.site.com/');" />     <table id="item-table">         <thead>             <tr>                 <th scope="col">date</th>                 <th scope="col">title</th>                 <th scope="col">type</th>                 <th scope="col">author</th>                 <th scope="col">description</th>             </tr>         </thead>     </table> </body> 

rss.xml

<rss version="2.0"> <channel>   <title>site title</title>   <link>http://www.site.com</link>   <language>en-us</language>   <pubdate>sun, 03 jul 2011 14:40:50 +0000</pubdate>   <lastbuilddate>sun, 03 jul 2011 14:40:50 +0000</lastbuilddate>   <copyright/>    <item>     <title>       [art] - title     </title>     <link>http://www.site.com/id?=333</link>     <author>author</author>     <description>this description</description>     <pubdate>sun, 03 jul 2011 12:38:12 +0000</pubdate>   </item>    <item>     <title>       [music] - title     </title>     <link>http://www.site.com/id?=332</link>     <author>author</author>     <description>this description</description>     <pubdate>sun, 03 jul 2011 12:14:53 +0000</pubdate>   </item>  </channel> </rss> 

found problem: when creating xml file php database field description empty on 1 of entries causes tag output <description />. fixing <description></description> solves problem.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -