How To Create an RSS feed from a Javascript-Generated HTML Table - javascript

I have a website with a table that is populated with data from various external XML feeds. The table is generated using Javascript as after some reading, I found that this seemed to be the best approach for creating an HTML table from XML data (please correct me if wrong!).
I now want to parse this HTML table in to an RSS feed and I'm struggling to find the best way to do so. I have php code that will parse an HTML table, but because this table is generated using JS (ie. client side) the PHP parser does not work. Can anyone tell me the best way to go about this?
As you've probably gathered, I'm quite new to programming so layman terms would be much appreciated where possible.
Thanks a lot.

I found that this seemed to be the best approach for creating an HTML table from XML data (please correct me if wrong!).
As a rule of thumb, if instant feedback isn't required (and it isn't if you are fetching data from multiple external sources), if you can do it server side, then do it server side. You only have one server side environment to deal with instead of dozens of different client side environments (some of which could have JS turned off).
I now want to parse this HTML table in to an RSS feed and I'm struggling to find the best way to do so. I have php code that will parse an HTML table, but because this table is generated using JS (ie. client side) the PHP parser does not work. Can anyone tell me the best way to go about this?
Write PHP to get the data from wherever the JS gets its data from. You already have the logic to query it in JS, so you should be able to do a fairly straight port of that.

It is not possible to generate an RSS feed from pure JavaScript, as most RSS clients don't speak JavaScript, and the standard doesn't provide for it - you won't be able to run the commands required to create the data.
Replicate the functionality of your JavaScript aggregator using some server-side language like PHP, and build an RSS feed from it. It will require rewriting your entire code, but probably is the best way to go.

Related

Web app : Best technology to develope an interface for a database?

I am new to web development;
I am trying to develop some web application to view data and do insert and delete on a little database including two tables.
I use Node.js for my server.
Currently, the data is saved in two XML files. I do my operations(insert,delete,...) by changing the XML at clientside and sending the XML over to server to be saved.
However, I guess this is the hard and native way and there should be some library or some technology to help, because this is such a common scenario.
I also think that using some database rather than XML may help, though the database management utilities are not much needed really.
Note: I don't browse all the data directly from database. the database includes path of some images which are loaded for the user to be viewed.
Any idea is appreciated. Thanks.
I would suggest sqlite as the way to go! U will find an abundance of information on how to use it if U google it.
Have a look at this : https://codeforgeek.com/2014/07/node-sqlite-tutorial/ it may be the answer to the question U are asking :)

Cache html page but not data

I have html_page.php that contains my html page,
javascript.js contains ajax to call process.php which lookup data from MySQL and populate into html_page.php.
Is it possible for me to cache the HTML structure of html_page.php but not the data in the fields?
It is hard to give you a proper answer without you giving us a context you are working on, but according to your question tags, I assume you are talking about using PHP.
You should refer to this thread on implementing caching on a PHP site.
Typically, you will need to use plugins and extensions that don't come out-of-the-box with PHP.
Some web servers also have caching functionality built into them, you should look up the documentation of your web server.

Create database in memory from sql/csv files in Javascript

I am creating a product that as end result will/can create e.g. 10 .sql files, each being a table. The tables will contain various pre-calculated data related to each other.
My users will need to upload these to their website (php, asp, whatever) and will need to make something useful. Only problem, the users may have next to zero understanding of databases, server-side code etc. This means it must be very easy to configure.
So I think thinking upload these .sql (or CSV files, whatever) tables to server, so they are publicly available (i.e. can be retrieved like any other public URL). And then find a Javascript in-memory database engine that can load .sql database files. Does this exist?
I imagine a Javascript solution could work well if amount of data could be kept somewhat down... Otherwise I may need to look for a PHP/ASP solution as well. (Any ideas for libraries that can init in-memory databases from .sql or similar files?)
Preferably I should be able to re-distribute this Javascript library. (So users can get a complete "directory" of .sql files + example page + Javascript database engine to upload)
So to make the question clear: Anyone knows a Javascript-based in-memory database engine that can run inside browser?
If you wish to use javascript and need some 'userfriendly' bridge database, you could use json or xml, because the format are simple text files (like csv as well) for wich you can find smart small editors for your users.
More json is made for javascript parsing and has an understanding tree format, but you should load only some part of sql datas in memory, saying data buffers in xml or json, with php requested with some javascript ajax call. Php do the sql database access work and then you can output json, and with javascript, it is for user's interface, you'll be able to display them.
You can use mysql to store a database in memory:
http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html
Here's a pure JS SQL engine that stores everything in memory, https://github.com/moxley/sqittle
It flatly denies being useful for anything though, and has a limited set of supported commands (see readme on above link.
http://diveintohtml5.ep.io/storage.html might be what you are looking for.
That question seems very old. You might want to look at LokiJS now.

RSS to JSON phonegap

I'm writing a phonegap application (i.e. no cross domain restrictions for AJAX) that needs to parse RSS feeds (i.e. extract information), I was looking for an easy way to do this. I looked at this, which seems good, but, I would rather not connect to external sources since the app should run on pretty slow internet connections too and each extra connection is a problem. What do you guys suggest? JSON seems like an excellent idea, but, any direct ideas are great as well.
I had the same issue.
But I don't recommend processing the RSS on each call... This is madness.
Neither do I recommend loading the whole RSS as JSON... It's even worst.
Those techniques add delay to a connection which might be really slow.
What I did was a bit more complicated but you have full control over what you send.
I'll assume that before loading any articles you'll show a list of titles to choose from...
So, first of all, you need to parse the whole RSS with php (or other server side language) and you'll output JSON formatted text files:
1. A text file containing the list of all articles with their id and title (img path, date, if needed)
2. A text file for each article named rssfeed_[id]
You put a CRON task on that script and ensure that everything is gzipped.
Then you create a small php file to handle the name & id of your file as parameters (that you'll get from the list).
Finally in your application you call one unique php file that will get dynamically any file needed without any processing of XML (RSS) to JSON

List of files using webserver side script

Require some advice to get me started.
Just trying to do something simple at the moment for learning purposes.
Written a simple html page, with some javascript on a 'client'.
I need a way of getting a file list from my own webserver (including info such as date modified), that I can run from my simple page somehow.
So my question, is javascript + ajax the way I should be approaching this, or is there an easier/better way. Links to tutorials/examples greatly appreciated.
Thanks.
You need to write two scripts:
One that scans a particular directory on webserver and generates results in a format suitable for AJAX (I would recommend JSON format but not JSON-P).
An AJAX script that queries the script, formats and displays the data.
What server side scripting languages are you familiar with?
is javascript + ajax the way I should be approaching this
That would be only part of the solution. You will also need to write a server side script which will return the list of files and then you could query this script using AJAX by passing it the script name yuo would like to get info about. The reason why you might need a server side script is because javascript has no direct access of server files and information like date modified.
HTML and JavaScript run on client side. You need a server side technology to parse the file list on your web server and throw the output in HTML. Some server side technologies are ASP.NET, PHP, NodeJS etc.

Categories