XML DOM Parsing in Java <font size=-2><a href=http://www.lifemichael.com/en/?page_id=73 target=_blank>PRO</a></font>

JAXP (Java API for XML) provides us with the capability to parse XML documents using a DOM parser. The following code sample shows a simple parsing using the JAXP DOM parser. package com.abelski.samples; import java.io.IOException; import java.net.URL; import java.io.InputStream; import java.net.HttpURLConnection; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; […]

HTML5 Relational Database <font size=-2><a href=http://www.lifemichael.com/en/?page_id=73 target=_blank>INFO</a></font>

HTML 5 provides us with a relational database running on the web browser. This relational database supports SQLite sql syntax. The following code sample checks whether the web browser supports the HTML 5 relational database. <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <title></title> </head> <body> <script type=”text/javascript”> if(window.openDatabase) { document.write(“support”); } else […]

Writing to Java Script Console <font size=-2><a href=http://www.lifemichael.com/en/?page_id=73 target=_blank>PRO</a></font>

We can easily track our code in Java Script by writing text messages to the Java Script console. The following code sample shows how to do it. <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <title></title> <script type=”text/javascript”> var sum = 0; for(i=1; i<=10; i++) { sum+=i; console.log(“i=”+i); console.log(“sum=”+sum); } document.write(“sum=”+sum); </script> </head> […]

Simple Trait in PHP <font size=-2>PRO</font>

Defining a trait is very similar to defining a class. Instead of using the keyword class we use the keyword trait. The purpose of traits is to group functionality in a fine grained and consistent way. It is not possible to instantiate a trait. The trait servers as an additional capability that provides us with additional capabilities when […]

Arrays Short Syntax in PHP 5.4 <font size=-2>PRO</font>

As of PHP 5.4 we can create new arrays in a simple way. Simpler than ever. The following code sample shows that. <?php $vec_a = [4,6,2,7]; $vec_b = [‘a’=>’australia’,’b’=>’belgium’,’c’=>’canada’]; foreach($vec_a as $k=>$v) { echo ” “.$k.”=>”.$v; } foreach($vec_b as $k=>$v) { echo ” “.$k.”=>”.$v; } ?> The following video clip shows the execution of this […]

Array Dereference in PHP 5.4 <font size=-2>PRO</font>

As of PHP 5.4 we can develop a function that returns an array and treat the call to that function as an array we want to access its elements. <?php function doSomething() { $vec = [23,53,75,64]; return $vec; } echo doSomething()[0]; ?> The following video clip shows the execution of this code sample and explains […]

The PHP 5.2 filter_var Function <font size=-2>PRO</font>

PHP 5.2 adds the filter_var function. It is an important function that assists with validating the user input. <?php $email_address_dirty = “haim.michael@gmail.com”; if(filter_var($email_address_dirty,FILTER_VALIDATE_EMAIL)) { $email_address_clean = $email_address_dirty; } echo $email_address_clean; ?> The following video clip shows the execution of this code sample and explains it.

PHP 5.4 Short Tags <font size=-2>PRO</font>

As of PHP 5.4, the support for short tags exists by default. There is no need to introduce changes into php.ini in order to use the PHP short tags. <? $numA = 24; $numB = 4; ?> <h1><?=($numA+$numB)?></h1> The following video clip shows the execution of this code sample and explains it.