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.
Related
I have a local JSON file. I want to create an object of that file using JS.
I tried finding some solutions and they are simply too complicated
An answer suggests that "Being able to read a local file from your browser would be a major breach of security..." so does that mean that there is NO simple way to read a local file without using FileReader or XMLHttpRequest !?
I am very disappointed as I come from a Python background and there, you can simply use a one liner "open" function to read a file.
(PS: Please do not use any AJAX or jQuery in your answers/comments)
EDIT: Somewhat more detailed description.
I have 4 files in a folder. An HTML, a CSS, A JS and one JSON file. What I want is whenever, I try to load the HTML page in a browser, my JS creates a JSON object of my local JSON file which I can display in my HTML body.
I am in the process of moving a static HTML onto WordPress.
I am trying to figure a way in which I can pull specific HTML content from the files(title tags, description tags, <h1> tags, etc.). I have around 120 local files and doing it all by hand would be a long process.
However, if I could get this data into a CSV I can quickly move this site.
Does anyone have any advice or experience with this type of process? Any help would be greatly appreciated.
The question is about extracting certain HTML elements, out of a given HTML file. There are multiple ways to do this. Let me point out some of them below.
1) Use a script with a Library to do this. For Java use JSOUP.
String br = "<html><source>foo bar bar</source></html>";
Document doc = Jsoup.parse(br, "", Parser.xmlParser());
for (Element sentence : doc.getElementsByTag("source"))
System.out.println(sentence.text());
}
This will give you the list of elements with the HTML tag source. You can do the same for other languages like python (use BeautifulSoup) and NodeJS.
2) You can write a script to read HTML files as text files and do a search on text.
Move all your HTML files into a folder, and write a small program to load each file and search for the specific tags. Later save it to a CSV or any preferred output.
3) You can do the same with grep.
Simple do a search and load the results directly into a CSV file.
There are multiple other ways to do it. Since you mentioned that the manual workload is higher, try doing a small script to get the job done. Use the first approach as it is faster and easier.
I have two HTML files that are generated from a particular application; one is a navigation "header" file and the other is a "content" file that the navigation file points to.
I have access to these files but I don't have control over how they're generated.
The files currently fit together by a third file "index.html". The index file uses document.write() to create a frameset tag and then two frame tags, one for each HTML file noted above.
I'm writing a replacement index.html file that mimic's the frameset with section tags and then adds in some features that allows the user to perform processes on the "content" html file.
So far I'm able to accomplish this by using the jquery load() method to grab the navigation and content files, but when I take the files offline (these files are meant to be consumable directly from the desktop) it does not work. I read into the jquery documentation for load() and see that it needs to be run from a server.
My questions is: is there any way to load the content from one html file into another html file without being in a hosted environment? I've seen it work in other solutions like the bwip-js and it looks like it's just using the jquery load(), but there must be something I'm missing.
Any suggestions?
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!
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.