Changing Class and style Of An Html Element

April 24, 2009

To change the class of an html element using javascript

use

document.getElementById(‘id_value’).setAttribute(“class”,”new _class”);

To hide the display of an element

use

document.getElementById(‘id_value’).style.display = “none”;

Note: in the same fashion any attribute and style may be changed

Zend_Dom_Query

April 10, 2009

Zend_Dom_Query is a class which is used to acess the elements on an html or a xml file

These elements may be acessed as

<?php

require_once(‘Zend/Dom/Query.php’);

$url = “proper url of the file”;

$data = file_get_contents($url);

$dom = new Zend_Dom_Query($data);

$info = $dom->query(‘xpath of the element’);//return a dom object

foreach($info as $data)

{

echo$data->nodeValue;

}

?>

example

$url = “http://www.xyz.com/param/abcd1234&#8243;;
$total_info = file_get_contents($url);
$dom = new Zend_Dom_Query($total_info);
$property = $dom->queryXpath(‘/html/body/center/div/div/div/div/div/div/table/tr/td’);//using xpath
$property = $dom->query(‘h2[style=”padding: 10px 0px 10px 20px; font-size: 14px”]’);//using css style
$property = $dom->query(‘b>label’);//using label tag which is under div
$property = $dom->query(‘.formTable .viewList div’);//querying div which is decendent of element having viewList class which is decendent again of element having formTable class.
$property = $dom->query(‘/html/body/center/div/div/div/div/div/div/table/tr/td/div/b’);
$property = $dom->query(‘/html/body/center/div/div/div/div/div/div/table/tr/td/div/div’);
//we can use query also instead queryXpath
$property = $dom->queryXpath(‘//label’);
foreach($property as $key => $prop)
{
echo$key;
echo”<br/ >”;
echo $prop->nodeValue;
}

NOTE::———————-

1:::if u are using Mozilla plugin firebug for finding the xpaths of elements do remeber to remove tbody from the xpath if it exists because it is inserted by mozilla only

Inserting MSExcel Data directly into Database

March 30, 2009

In this procedure firstly convert .xls  file into .csv  format(using save as .CSV). After this  open the file into any notepad and then edit it to proper format so that it may be inserted into the DB. Just like

INSERT INTO `table name'(`column1`,`column2`)

Values (‘value1′,’value2’),(‘value3’,value4)

For the the shorter way is that  open the file in MS EXCEL and before each Column insert a new column with some special characters. Also insert  a column after the last column.

Add special characters like#$# for first new inserted column $#$ for all midlle new inserted column and &#& for the last column. Now open this .csv file into notepad and replace

,#$# with    (‘

,$#$, with  ‘,’

,&#& with  ‘),

Now replace exactly last character of the file that is (   ,  ) with ;

now put INSERT INTO and VALUES keywords at proper places  copy that data into sql of phpmyadmin and execute

That has done alll

cheers

Detection of warning

March 26, 2009

The process for detecting a warning inside php script is :

if(@simplexml_load_string(‘ path to some file ‘) == false)

this will check that whether the warning is there while loading the xml or not. we can use it in if and else structure.

Note: @ is used for warning subpression

Pear Installation

March 26, 2009

The pear package is bundled with php 5 and later versions.The command line installation process is

c:\>php PEAR\go-pear.php

This command will install pear package.

Hello world!

February 23, 2009

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!