Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create a JSON feed
    primarykey
    data
    text
    <p>I have a file called parsing.html that parses through a xml feed and converts the metadata into <code>JSON</code> Object called "data". I'm trying to output this <code>JSON</code> "data" as a JSON feed such as <a href="http://www.videws.com/gtv/videosources.php" rel="nofollow">http://www.videws.com/gtv/videosources.php</a>. Is doing <code>document.write(JSON.stringify(data))</code> the equivalent of creating a <code>JSON</code> feed in this case?</p> <pre><code>$.ajax({ type: 'GET', url: 'fakeFeed.xml', dataType: 'xml', async: false, success: function(data, textStatus, jqXHR) { function getRandom(max) { return Math.floor(Math.random() * max); } function getThumbId(small) { var num = getRandom(15); if (num == 0) { num = 1; } if (num &lt; 10) { num = '0' + num; } return num.toString(); } var categories = new Array(); // Array for the categories var category = { name : '', videos: [] }; var data1 = data; var data = { categories: [] }; $(data1).find('item').each(function () { var el = $(this); var categoryName = el.find('category').text(); var p = categories.indexOf(categoryName); if( p == -1) { categories.push(categoryName); var category = { name: categoryName, videos: [] }; for (var j = 0; j&lt;5; j++) { var video = { sources: [el.find('media\\:content, content').attr('url')], thumb : 'images\/thumbs\/thumb' + getThumbId() + '.jpg', title : el.find("title").text(), subtitle : el.find("description").text(), description: "" } //document.write(categories); category.videos.push(video); } data.categories.push(category); } }); document.write(JSON.stringify(data)); } }) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload