html to Generate or update xml from file list? - javascript

so im making a javascript image gallery for a friend- and he wants to be able to add new images later. Right now i have javascript generate the gallery from an xml file (which is created by custom picassa export). is it possible to have the html file update the xml file with new images- it needs to be able to add a couple tags for the format and know the file name. is it possible without using php?
thanks

If you're using JavaScript to parse the XML file, it will update with new content when he adds it to Picassa. Don't download the Picassa XML file, you should be able to link directly to it.

Related

How load several HTML files as "document" and then manipulate them with Javascript?

I want to create and manipulate several HTML files with JavaScript and NodeJS. The usual way to update HTML files is to include an update script at the top, but I want to create multiple HTML files with one JS file. I have a list with the necessary data to process. It contains the names for the HTML files and the data to put in.
My idea was to use a model.html file, which contains the data, that will be included in all of the files. This model file will be copied and renamed to the necessary file. Then I want to load it with a NodeJS module or any other way fit, so it will be recognized as "document" as if the script was included in the file. Then I want to manipulate it with plain JS. A for loop should iterate through the list and create the file, load it as "document", manipulate it and then go to the next file.
Is this possible?
If you want to just parse the HTML and get the document and operate on it you can check https://cheerio.js.org/
If you want to execute the Javascript also then you need to use Headless browsers like Headless Chrome

Call multiple XML files into HTML

I understand the basics of XML - HTML. Working on sport feed site, the feeds file names change all the time. For example:
xt.222500-01.xml
xt.222501-02.xml
and so on...
Each file have the same content and I have setup the tables in HTML to display from XML. Traditional in JavaScript you call the file that you hard code in.
How do you call XML files that change all the time?
Thanks for you help.

How can I add a list of image files to a zip file using zip.js?

I have a list of images and an HTML string which holds a web page containing the images. I would like to create a zipped file via JavaScript code by using zip.js and save it at runtime.
The creation of the htmlString to file.html was easy, but I'm not sure on how I can send this list of images to zip.js.
I thought to create dynamically via JavaScript a list of input file elements maybe via jQuery or something, but I still cannot figure out how to do it. Does there exist some way to do that?
If I understand correctly, you managed to create the list of files (array?) and your issue is to create the zip file that contains the files.
If this is the case you can try using this small package :
https://www.npmjs.com/package/list-to-zip
It accept an array of urls and create a zip file from it.

HTML5 with javascript to parse and display textfile

I have an HTML5 page (index.html), and I need to display the contents of a .txt file (p001wide.txt). Both are on the server in the same directory.
The text file is generated from a CMS, so I cannot change the format of that file.
In the .txt file is a variable named widetxt. I need to display the contents of the widetxt variable on the page.
What do I need to do to parse the the textfile and display it in the HTML page?
Do I need to use javascript, and if so, how?
Hm, I found this question which appears to be similar to yours as far as reading a file goes. As for parsing though why not use a database such as MySQL to store your data? This way you can quickly add and query through your data.
As both your index file and the text file you wish to read reside on the server you should be able to read the text file on the server and insert what you wish from it into the index file using PHP.
See http://www.w3schools.com/php/php_file.asp for a tutorial on how that can be done without resorting to client side script.
If you cannot alter your index file on the server and can put a PHP file on the server you can use AJAX to ask your PHP file to read the contents of the text file and return it to you. Then you would use javascript to insert it as you wish. I presume that you can alter the index file because otherwise you could not alter its javascript either.
You can do this with JavaScript, you basically need to learn how to read and write files (and you mention the variable inside, this would be parsing). Start reading here - http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm other information, just Google read write files javascript, or parsing text with javascript.
Best of luck!

picking up a path in a javascript file

I need some help with my js file. I an using a bit of javascript to show some xml on a page and I need to reference the right xml file according to the page that it is on. e.g.
<script>
xml=loadXMLDoc("product.xml");
</script>
I have the all the xml files named as different products and have printed out the reference to the xml on the page that it should be on
<div id="product">/xmlfolder/item001.xml</div>
What I need to do is somehow reference the path on the page to the javascript. Is this possible?
Thanks
Do you mean
xml=loadXMLDoc(document.getElementById('prodct').innerHTML);

Categories