Pages

Accessing a Xml File on Server using JavaScript

  1. Create a XML file static or dynamic in Server
  2. Write a javascript function as shown JavscriptFunctionCode shown below .
  3. Call a method loadXMLDoc("XML filename")
  4. Parse XMl as shown Pseduo Codefor futher ways to parse XML document visit http://www.w3schools.com/dom/

Javasript Function Code (ref:w3schools)

function loadXMLDoc(dname) { try //Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } catch(e) { try //Firefox, Mozilla, Opera, etc. { xmlDoc=document.implementation.createDocument("","",null); } catch(e) {alert(e.message)} } try { xmlDoc.async=false; xmlDoc.load(dname); return(xmlDoc); } catch(e) {alert(e.message)} return(null); }

Pseduo Code

/////Xml File <?xml version="1.0" encoding="iso-8859-1" ?> <shop> <product> <category>Electronics</category > <pname>LapTop</pname> <cost>50</cost> </product> <product> <category>Entertainment</category > <pname>Lg Tv</pname> <cost>500</cost> </product> </shop> //////////////////////////////// ///javscript calling code xmlDoc=loadXMLDoc("Products.xml"); //one of the way of parsing xml eleement document.write(xmlDoc.getElementsByTagName("category")[0].childNodes[0].nodeValue); ////////////////////////////////

Sorting & Filtering Data Using DataView In Asp.net 2.0

Steps:

  1. Create Dataview Object pass DataTable object to constructer of Dataview class (Assume datatable object is Created)
  2. To sort Data use property called 'Sort' in Dataview object as peseduoCode shown below .
  3. To Filter Data use RowFilter or RowStateFilter.as peseduoCode shown below
  4. RowFilter is use as where clause in sql statment use all operaters use in where clause
  5. RowState Filter provide base on DataRow object RowState property.It is use to retrive version information with DataTable using one of the DataViewRowState enermuation

DataViewRowState Enermuation

  • Added:Retervies the current DataRowVersion of DataRow Object that row state of Added
  • CurrentRows:Reterive all rows that current DataRowVersion
  • Deleted:Reterive the original DataRowVersion of DataRow object that have a RowState of deleted.
  • ModifiedCurrent:Reterives the Current DataRow Version of DateRow object that have RowState of modified
  • ModifiedOriginal:Reterives the Original DataRow Version of DateRow object that have RowState of modified
  • None:Clears Row state filter property
  • OriginalRows:Reterive the DataRow object that have original DataRowVersion.
  • Unchanged: Reterive DataRow object that have row state of unchanged

PseduoCode

////Dataview Sort
DataView view = new DataView("datableobject"); view.Sort= "columname1 ASC , columnname2 DESC"; ///Binding datasource gird; gridobject.DataSource=view; gridobject.DataBind();
////////////////// ////Dataview RowFilter
view.RowFilter ="columname1 like '%A' and columname2 < 26 "; //Do Some Thing
////////////////////// ////DateView RowState property
view.RowStateFilter = DataRowState.Added //DataRowState.Enumerationnames //Do Some Thing