How to display 100K XML based DOM data on a JSP client page? - javascript

I need some help in understanding what to do next.
I need to write a web based search function to find medical records from an XML file.
The operator can enter either part or all of a patient name and Hit Search on the JSP web page.
The server is suppose to then return a list of possible patient names with the opportunity for the operator to go to next page until a possible patient is found. They can then select the person and view more details.
On the Server side
I have an XML file with about 100,000 records. There are five different types of records in the file. (This is roughly about 20,000 x 5 = 100,000).
I have a java class to source the xml file and create a DOM to traverse the data elements found on the file.
-- XML File Begin
100k - XML file outline
<infant key="infant/0002DC15" diagtype="general entry" mdate="2015-02-18">
<patient>James Holt</patient>
<physician>Michael Cheng</physician>
<physician>David Long</physician>
<injury key="injury/0002IC15" diagtype="general entry" mdate="2015-03-14">
<patient>Sara Lee</patient>
<physician>Michael Cheng</physician>
<terminal key="terminal/00X2IC15" diagtype="terminal entry" mdate="2015-05-14">
<patient>Jason Man</patient>
<physician>John Hoskin</physician>
<aged key= xxxx ... >
<sickness key= xxxx ... >
approx 5 ( )x 20,000 = 100K records.
Key and patient are the only mandatory fields. The rest of the elements are Optional or multiple elements.
-- XML File End
Here is where I need help
Once I have the DOM how do I go forward in letting the client know what was found in the XML file?
Do I create a MAP to hold the element node links and then forward say 50 links at a time to the JSP and then wait to send some more links when the user hits next page?
Is there an automated way of displaying the links, either via a Java Script, Jquery, XSLT or do I just create a table in HTML and place patient links inside the rows? Is there some rendering specific thing I have to do in order to display the data depending on the browser used by client?
Any guidance, tutorials, examples or books I can refer to would be greatly appreciated.
Thank you.

I don't know an automatic way to match the type in jQuery, but you can test the attributes, something like verify if a non optional attribute in the object is present:
// Non optional Infant attribute
if(obj.nonOptionalAttribute) {
// handle Infant object
Or you may add an attribute to differentiate the types (something like a String or int attribute to test in your Javascript).
if(obj.type == 'infant') {
// handle Infant object

You can try to bind the XML to a list of objects (something like Injure implements MyXmlNodeMapping, Terminal implements MyXmlNodeMapping, Infant implements MyXmlNodeMapping and go on and have a List) to iterate and search by the value at the back end or you can pass this XML file to a Javascript (if you are using jQuery you can use a get or a post defining the result type as XML) and iterate over the objects to find what the user is trying to find...
Your choice may be based on the preference to use processor time in the server side or in the client side...


Importing text file contents to database

I'm working with sensor units outfield that spit out data in the form of native text files and have a database created with pre-defined tags. E.G mm, level, voltage. The text file I'm using is pretty unstructured with the data being on the right side of the header separated by semicolon delimiters.
I want to try and import the content into the database where each header matches the tag name and the values are inserted into that tag consecutively. I'm wondering if there's a possible solution or maybe even some tips on how i can achieve this?
Currently i have been working with PHP but haven't gotten to far, is it the best language to use for such a method? Or would javascript be preferred?
Text file is delimited by semicolons:
L;MINVi;Min voltage;V;PTi;Processor temperature;C;AVGVi;Average voltage;V;SDB;Network signal dB;dB;WL02;waterlevel 2m;cm;RSSI;Network signal indication;RSSI;OCi;Operating cycle;sec;SCNT;Satellites;;LAT;Latitude;deg;LON;Longitude;deg
S;170427000428;ERR;SERVER_LOGIN;+CME ERROR: Bad or no response from server
S;170427000518;ERR;SERVER_LOGIN;+CME ERROR: Bad or no response from server
S;170427000647;ERR;SERVER_LOGIN;+CME ERROR: Bad or no response from server
S;170502171807;SYS_START;BHSDemo 5170991
S;170502171823;WDT;Network signal
database table Tag_data Structure
You can do like this
Your text will be pretty hard to explode every value with it's parameter because every single word end with ; so, first try to make your text file like parameter:value; or parameter=value; or parameter_value; then you can read the content of this file with this php function $content = file_get_contents("path/text_file_name.txt"); now the value of $content variable is equal to the entire text of your file hence, you can split this variable into an array with $splittedcontent = explode(";" , $content); every parameter:value is a parameter in this array like $splittedcontent[0] = parameter0:value0, $splittedcontent[1] = parameter1:value1 and so on, now you can use for loop throw this array and make what your need in you database..
I hope this will help you.

Search for "id" and return all the relevant information

I have a log file called test.log (for demo purposes - which I have simplified by a lot!) which looks like this:
2016-16-03 16:23:22,030 INFO [session] RESPONSE {api=GetSession, URL="http://testing/123ab-1234-abc/123ab-1234-abc.m3u8"}
2016-16-03 16:23:23,879 INFO [session] RESPONSE {api=KeepAlive, Ip=, result=success}
2016-16-03 16:23:23,879 INFO [info] REQUEST {httpMethod=PUT,result=false}
I have a simple web UI which has an "ID" field, and a search button.
So If the user searches for ID = 123-ab-123-abc
They front end UI will return this log event (as it contains the ID they are looking for):
2016-16-03 16:23:22,030 INFO [session] RESPONSE {api=GetSession, URL="http://testing/123ab-1234-abc/123ab-1234-abc.m3u8"}
This may seem like a simple concept, however I am not sure how to achieve this using Node.js - how do I search the log file and return the whole log event which contains that specific ID/string the user inputted?
I have tried:
transforming the log file into a json object, however that did not work as some numbers would end up as string, and some parts of the log file would loose their values.
Separating the log file into separate String values- as every event starts from a date - and then just returning the whoel string which contains the ID - however code wise I did not get far with this option
Any other ideas/ tips on how to achieve this?

Pass an HTML file object from one <input type = file> to another

I want to implement a multiple file uploader in a form wherein I want the files so that the user may sort the priority of the files (I am using draggable and sortable Jquery tool).
Therefore I have added a multiple file input as:
<input type = "file" multiple>
Now when I select some files, it shows say 3 files selected.
But when I select 3 files, I wish to split the file uploader in 3 parts so that the user may set the priority ordering accordingly.
For that I have used the following kind of code:
var filesSelected =;
if(filesSelected.length > 1){ //if user selects multiple files, then automatically split the files into multiple divs so that he/she may do the ordering of files
//Here I want to create a list of all the files and implement the draggable and sortable thing.
The situation is, that I am not able to split the array of objects of FileList and assign each object to another input.
Hope I am clear in my doubt and the question is understandable, as it is the first time I am posting in any such forum.
You cannot set value for <input type="file"> programmatically. It would be a major security flow. Imagine some website automatically uploading arbitrary files from your computer.
You can try to iterate through the selected files and then create a div dynamically with jquery that contains the data from the file like this
var filesSelected =;
if(filesSelected.length > 1){
for(var i=0;i<filesSelected.length;i++) { // We iterate through the selected Files
$("#idFromParentElement").append('<div> id=File'+i+'</div'); // Then we create and append the new div to the parent element of our choice
var fileId = 'File'+i;
$("#fileId").data("file",filesSelected[i]); //After that we include a data into the div with the selected file.
From the posts I received and the brief discussions, it is evident that setting file values programmatically will pose security threat and so is not a good option. As far as solving my issue is concerned, best would be to find a way to create multiple divs/fields containing the filenames of the files that are being uploaded and then applying the drag/drop/sort feature in that set of divs. This way the user can easily prioritize the files and while saving the form the array/field containing the priority shall be considered before saving the files data in the database.
Thanks to the responders for their quick response.

Possible to dump AJAX content from webpage?

I would like to dump all the names on this page and all the remaining 146 pages.
The red/orange previous/next buttons uses JavaScript it seams, and gets the names by AJAX.
Is it possible to write a script to crawl the 146 pages and dump the names?
Does there exist Perl modules for this kind of thing?
You can use WWW::Mechanize or another Crawler for this. Web::Scraper might also be a good idea.
use Web::Scraper;
use URI;
use Data::Dump;
# First, create your scraper block
my $scraper = scraper {
# grab the text nodes from all elements with class type_firstname (that way you could also classify them by type)
process ".type_firstname", "list[]" => 'TEXT';
my #names;
foreach my $page ( 1 .. 146) {
# Fetch the page (add page number param)
my $res = $scraper->scrape( URI->new("[gotopage]=" . $page) );
# add them to our list of names
push #names, $_ for #{ $res->{list} };
dd \#names;
It will give you a very long list with all the names. Running it may take some time. Try with 1..1 first.
In general, try using WWW::Mechanize::Firefox which will essentially remote-control Firefox.
For that particular page though, you can just use something as simple as HTTP::Tiny.
Just make POST requests to the URL and pass the parameter tx_lfnamelists_pi2[gotopage] from 1 to 146.
Example at for page #30.
Moral of the story: always look in Chrome's Network tab and see what requests the web page makes.

How to create a search function using Javascript or Jquery for Bible verse for instance

I'm trying to create a link of drop down list for the Bible on my webpage, I'm new to this thing. What I want is to do is to be able to select or ask the user to input the verse that they want to go to and then click Submit button then take that to the section of the Bible. For instance, if the user input Mathew 1: 2-10, this should take them to that section of that line of the Bible verse. How do I start doing this? and is Javascript and Jquery even the correct script to use or I need to use other programming language?
Thank you.
If you are planning to store the Bible text in a data base on a server, then you would need two programming languages: one for the server and one for the client (browser). JavaScript (with or without jQuery) would be a good tool for the client. Alternatives would be ActionScript (Flash) or a Java applet, but I would not recommend either of them for this.
On the server side, it completely depends on the nature of the server. Probably the most common combination is PHP and MySQL, although there are lots of other possibilities. For instance, you could store the data in XML files on the server and use XSLT to format the results for display in HTML on the client. That's the approach taken by (for the Hebrew Bible).
Intrigued by such a task I was wondering. Yes it can be done, but don't just wave away #Ted his comment. It will indeed be a better option to choose for a database application.
But yes, if you don't mind the work and just use it on a small scale, it is possible to create a javascript based application to serve your pages.
You could use an iframe to serve your pages. With creating a selection box that populates a second one, it is possible to make an acceptable application. The pages are collected in javascript objects and served. In this example the domain of w3schools is used.
var Mathew = {
verses: ["verse2_1", "verse2_2", "verse2_3"],
verse2_1: "html/html_iframe.asp",
verse2_2: "tags/tag_select.asp",
verse2_3: "jquery/default.asp"
The first selection box will contain a hand coded option list
<select name="book" id="book">
<option value="choose">Please choose</option>
<option value="Mathew">Mathew</option>
<option value="John">John</option>
The second option list is automatically populated with the help of the javascript object.
function populateSecondSelect(book) {
if (book == "choose") {
$("#verses").append("<option>choose a book first</option>");
$("button").prop("disabled", true);
$("button").prop("disabled", false);
var obj = eval(book);
$(obj.verses).each(function () {
$("<option/>", {
name: this,
id: this,
value: this,
text: this
With the second selection made, the button can be clicked to serve the page:
function fetchVerse() {
var book = $("#book").val();
var verse = $("#verses").val();
var url = baseUrl + eval(book + "." + verse);
$("#frame").attr("src", url);
The whole thing is working in a fiddle:
It is fun, but a database for a whole bible is better ..