Friday, 15 June 2012

HTML table to XML in JavaScript


Please note this code will now be hosted github :

https://github.com/aetuk/wasjsapi/blob/master/tabletoxml.js

getCheckedRowsXml = function(htmltablename, xmltablename) {
var rowsIndex;
var xmltable = '';
var xmlrow = '';
var rows = document.getElementById(htmltablename).getElementsByTagName(
'tbody')[0].getElementsByTagName('tr');
for (i = 1; i < rows.length; i++) {

// Xml defined based on a ‘checked’ checkbox - Feel free to add your
// criteria here to filter the data selected ( or not)
if (rows[i].getElementsByTagName('td')[0]
.getElementsByTagName('input')[0].checked) {
// here "i" is the row number if checked

var cells = rows[i].getElementsByTagName('td');
for (c = 0; c < cells.length; c++) {
// xmlrow = xmlrow + '
// '+cells[c].id+'="'+cells[c].innerHTML+'"';
xmlrow = xmlrow + '<' + cells[c].id + '>'
+ cells[c].innerHTML + '</' + cells[c].id + '>';
}
if (xmlrow != null)
xmltable = xmltable + '<row>' + xmlrow + '</row>';
xmlrow = '';
}
}
if (xmltable != null)
xmltable = '<' + xmltablename + '>' + xmltable + '</'
+ xmltablename + '>';
return (xmltable);
}

This function will return a xml representation of a HTML table for each  row on the table has a checkbox set to true in the form : <xmltablename><row><cell_name>cell_value<cell_name/><row/><xmltablename/>

It assumes that the html table has a checkbox on each row and that the name of the column is defined by cell id. Feel free customise it to suit your needs.

Sunday, 10 June 2012

Long term project success


In general great solutions stand the test of time with little or no maintenance - that differentiates a poor solution from a good one. A great solution takes this further and requires little effort to evolve. Successful projects are also governed by this rule.

Technology in most cases is not the limiting factor of producing a great long-term project outcome - it is the mindset and  imagination of project participants.

Critical success factors are defined during requirements stages, attempting to instill longevity into its the solutions foundations, by covering as many events and outcomes as possible as laid out by the business. But the theme of these factors is still governed by the project decision makers.So if simple, easy and seamless maintenance is not a priority then factors nvolving maintenance would be included as an afterthought or simply ignored when shaping the projects direction - Ultimately a functional but poor solution is achieved.

The maintenance aspect of the project is in most cases treated as an afterthought - especially if the project is handled by an external consultants - but its still the stakeholders responsibility to highlight maintenance as a central theme . Ignoring it displays a short-term attitude of the Return of investment. Maintenance has a huge impact on costs and time. A project may have cost 1 million GBP to complete but over the course of of 2 years maintenance cost may add 4 million to that value due to additional labour costs.  Investing in maintenance from the start may add 1 million GBP to initial project costs while reducing maintenance costs to 2 million.

For example you as a consultant has been tasked to create a ecommerce website 123 for company xyz. You have a choice of building an automated ETL mechanism to extract product data from an existing system, or you can enter this data by hand. So you present these options to the business with the associated advantages and disadvantages. If time to market takes priority , then the manual approach would most likely be selected. If maintenance takes priority then the ETL approach would be taken.

Successful projects requires maintenance to built in at its core.