HTML5 APPLICATIONS DEVELOPMENT MANUAL

(lu) #1

of_interest = "Kroger-04";
function init() {
var paragraph_object =
document.getElementById("paragraph");
var data_list = sample_data.split(';');
for (j = 0; j < data_list.length; j++) {
parts = data_list[j].split(':');
var site = parts[0].trim()
if (site == of_interest) {
var message = "Given the sample data '" + sample_data + "', this program parsed out the
price $" + parts[1].trim() + " for the " + site + " site.";
paragraph_object.innerHTML = message;
}
}
}





Parsing complex data


Welcome.




JavaScript and freely available JavaScript libraries supply a wealth of


parsing facilities.


Extraction of data from a human-readable external Web page is only


one instance among many of how JavaScript can parse data.


For example, you can also use a subset of JavaScript


calledJSON(JavaScript Object Notation) to exchange JavaScript objects


with a server.

Free download pdf