How to Read XML Using PHP DOM

This simple example mentions how the data from the xml file can be read and displayed in a textbox in the html file. It illustrates the concept which simplifies understanding the basics.

The structure of file.xml is:-


HELLO

This code lies in  file.php:-
<?php
 $xdoc = new DOMDocument( ‘1.0’, ‘UTF-8’ );
$xdoc->Load(“file.xml”);
$candidate = $xdoc->getElementsByTagName(‘root’)->item(0);
$newElement = $xdoc ->createElement(‘root’);
$txtNode = $xdoc ->createTextNode ($root);
$newElement -> appendChild($txtNode);
$candidate -> appendChild($newElement);
$msg = $candidate->nodeValue;
?>

This code lies in file.html



It will display the data in $msg variable in the textbox names msgval.

Advertisements

Creating A Xml Document Using XML DOM And PHP

I had many issues to dealing with while solving this problem i i though about sharing this. The code below illustates a simple logis to create a XML file if it is not present and create a root node. And looking at this node you can create chile nodes.

The code is as follows:-

<?php
$uvar = “HELLO”;
$doc = new DOMDocument(‘1.0’, ‘UTF-8’);
$ele = $doc->createElement( ‘root’ );
$ele->nodeValue = $uvar;
$doc->appendChild( $ele );
$test = $doc->save(“file.xml”)

?>

This will create a file.xml with the following contents:-
HELLO

Bing Makes Real Use of that Facebook Data

I had a given a exam on Information System Security few days ago as a part of my Engineering exams. It included topics about indexing, searching, page rank, popularity based ranking, Term Frequency – Inverse Document Frequency which are used to calculate values which determine the relevant page of your search query and display the list of relevant information. Though about sharing this with all of you as i found it interesting courtesy webpronews.
This might be interesting to know for users who use bing for their search on the web compared to that of widely used Google. Now BING introduces a new feature which will show you which of your Facebook friends have liked search results as they will appear in your searches and works towards proving you with more relevant links concerned with your search query. It will make more usage of the Facebook data. If a query shows which is liked by one for your friends it will show up as ‘Liked within Bing’. With this bing will be delivering social site results. The like feature on Facebook is popular feature which spreds the information very fast across your Facebook network like a wild fire. This could provide with you with more relevant information on a personalized level giving Bing and edge over Google.

Implementing procedures using parameters

Procedure for deletion of record

This is the procedure to which we are passing the parameter called in.
Write this procedure in oracle.

create or replace procedure del(n in number)
is
begin
delete from stud where rno=n;
end;

Write this code in VB. You can write this at onclick event of command button for example.

Set com = New ADODB.Command
com.ActiveConnection = con
com.CommandType = adCmdStoredProc
com.CommandText = “del(” & Text1.Text & “)”
com.Execute

SQL query Optimization or Query Evalution

Note: I have performed on oracle 10g wonder whether it will work on oracle 9i.

SQL> set autotrace on;
SQL> create table sailors (sid number(5) primary key, sname varchar2(10), rating number(5),
age number(5));

Table created.

SQL> create table reserves (sid number(5) , did number(5), day number(5), rname varchar2(5), CONSTRAINT col3_fk FOREIGN KEY(sid) REFERENCES sailors(sid) ON DELETE CASCADE);

Table created.

SQL> select * from sailors;

       SID SNAME          RATING        AGE
————— ————— ————— —————
         1 asss                1         22
         2 adfss               2         12
         3 affss               6         52
         4 afdss               6         32
         5 ddss                6         62
         6 iops                6         35

6 rows selected.

Execution Plan
—————————————————————————————
Plan hash value: 1417977701

——————————————————————————————————————-
| Id  | Operation         | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
——————————————————————————————————————-
|   0 | SELECT STATEMENT  |         |     6 |   276 |     2   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| SAILORS |     6 |   276 |     2   (0)| 00:00:01 |
——————————————————————————————————————-

Note
——-
   – dynamic sampling used for this statement

Statistics
—————————————————————————————
          0  recursive calls
          0  db block gets
          4  consistent gets
          0  physical reads
          0  redo size
        701  bytes sent via SQL*Net to client
        380  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          6  rows processed

SQL> select * from reserves;

       SID        DID        DAY RNAME
————— ————— ————— ——-
         1          1          4 asb
         1          1          4 asb
         2         12          7 sdb
         3         52          9 begb
         4         13          3 htyb
         5         17          6 bhjb
         6         27          8 qweb

7 rows selected.

Execution Plan
—————————————————————————————
Plan hash value: 3735829263

———————————————————————————————————————
| Id  | Operation         | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
———————————————————————————————————————
|   0 | SELECT STATEMENT  |          |     7 |   301 |     2   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| RESERVES |     7 |   301 |     2   (0)| 00:00:01 |
———————————————————————————————————————

Note
——-
   – dynamic sampling used for this statement

Statistics
—————————————————————————————
         88  recursive calls
          0  db block gets
         16  consistent gets
          0  physical reads
          0  redo size
        710  bytes sent via SQL*Net to client
        380  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          7  rows processed

Queries

1)
SQL> SELECT S.sname
  2  FROM Reserves R, Sailors S
  3  WHERE R.sid=S.sid AND S.rating>5;

SNAME
—————
affss
afdss
ddss
iops

Execution Plan
—————————————————————————————
Plan hash value: 1082800282

———————————————————————————————————————-
| Id  | Operation          | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
———————————————————————————————————————-
|   0 | SELECT STATEMENT   |          |     5 |   230 |     5  (20)| 00:00:01 |
|*  1 |  HASH JOIN         |          |     5 |   230 |     5  (20)| 00:00:01 |
|*  2 |   TABLE ACCESS FULL| SAILORS  |     4 |   132 |     2   (0)| 00:00:01 |
|   3 |   TABLE ACCESS FULL| RESERVES |     7 |    91 |     2   (0)| 00:00:01 |
———————————————————————————————————————-

Predicate Information (identified by operation id):
—————————————————————————-

   1 – access(“R”.”SID”=”S”.”SID”)
   2 – filter(“S”.”RATING”>5)

Note
——-
   – dynamic sampling used for this statement

Statistics
—————————————————————————————
          9  recursive calls
          0  db block gets
         16  consistent gets
          0  physical reads
          0  redo size
        473  bytes sent via SQL*Net to client
        380  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
          4  rows processed

2)

SQL> SELECT S.sname
  2  FROM Reserves R, Sailors S
  3  WHERE R.sid=S.sid AND
  4  R.did=1 AND S.rating
SNAME
—————
asss
asss

Execution Plan
—————————————————————————————
Plan hash value: 1694003264

———————————————————————————————————————-
| Id  | Operation          | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
———————————————————————————————————————-
|   0 | SELECT STATEMENT   |          |     2 |   118 |     5  (20)| 00:00:01 |
|*  1 |  HASH JOIN         |          |     2 |   118 |     5  (20)| 00:00:01 |
|*  2 |   TABLE ACCESS FULL| RESERVES |     2 |    52 |     2   (0)| 00:00:01 |
|*  3 |   TABLE ACCESS FULL| SAILORS  |     2 |    66 |     2   (0)| 00:00:01 |
———————————————————————————————————————-

Predicate Information (identified by operation id):
—————————————————————————-

   1 – access(“R”.”SID”=”S”.”SID”)
   2 – filter(“R”.”DID”=1)
   3 – filter(“S”.”RATING”
Note
——-
   – dynamic sampling used for this statement

Statistics
—————————————————————————————
          8  recursive calls
          0  db block gets
         16  consistent gets
          0  physical reads
          0  redo size
        446  bytes sent via SQL*Net to client
        380  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
          2  rows processed

3)

SQL> SELECT S.sname
  2  FROM Sailors S
  3  WHERE S.rating >
  4  (SELECT Avg(rating)
  5  FROM Sailors);

SNAME
—————
affss
afdss
ddss
iops

Execution Plan
—————————————————————————————
Plan hash value: 2915248218

———————————————————————————————————————-
| Id  | Operation           | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
———————————————————————————————————————-
|   0 | SELECT STATEMENT    |         |     1 |    20 |     4   (0)| 00:00:01 |
|*  1 |  TABLE ACCESS FULL  | SAILORS |     1 |    20 |     2   (0)| 00:00:01 |
|   2 |   SORT AGGREGATE    |         |     1 |    13 |            |          |
|   3 |    TABLE ACCESS FULL| SAILORS |     6 |    78 |     2   (0)| 00:00:01 |
———————————————————————————————————————-

Predicate Information (identified by operation id):
—————————————————————————-

   1 – filter(“S”.”RATING”> (SELECT AVG(“RATING”) FROM “SAILORS”
              “SAILORS”))

Note
——-
   – dynamic sampling used for this statement

Statistics
—————————————————————————————
          8  recursive calls
          0  db block gets
         15  consistent gets
          0  physical reads
          0  redo size
        473  bytes sent via SQL*Net to client
        380  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          4  rows processed

4)
SQL> SELECT S.sname
  2  FROM Sailors S
  3  WHERE EXISTS
  4  (SELECT *
  5  FROM Reserves R
  6  WHERE R.sid=S.sid);

SNAME
—————
asss
adfss
affss
afdss
ddss
iops

6 rows selected.

Execution Plan
—————————————————————————————
Plan hash value: 15409597

———————————————————————————————————————-
| Id  | Operation          | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
———————————————————————————————————————-
|   0 | SELECT STATEMENT   |          |     6 |   198 |     5  (20)| 00:00:01 |
|*  1 |  HASH JOIN SEMI    |          |     6 |   198 |     5  (20)| 00:00:01 |
|   2 |   TABLE ACCESS FULL| SAILORS  |     6 |   120 |     2   (0)| 00:00:01 |
|   3 |   TABLE ACCESS FULL| RESERVES |     7 |    91 |     2   (0)| 00:00:01 |
———————————————————————————————————————-

Predicate Information (identified by operation id):
—————————————————————————-

   1 – access(“R”.”SID”=”S”.”SID”)

Note
——-
   – dynamic sampling used for this statement

Statistics
—————————————————————————————
          8  recursive calls
          0  db block gets
         16  consistent gets
          0  physical reads
          0  redo size
        494  bytes sent via SQL*Net to client
        380  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
          6  rows processed

5)
SQL> SELECT S.sname
  2  FROM Sailors S
  3  WHERE EXISTS
  4  (SELECT *
  5  FROM Reserves R
  6  WHERE R.did=1
  7  AND R.sid=S.sid);

SNAME
—————
asss

Execution Plan
—————————————————————————————
Plan hash value: 2677790372

————————————————————————————————————————

——————

| Id  | Operation                    | Name        | Rows  | Bytes | Cost (%CPU)

| Time     |

————————————————————————————————————————

——————

|   0 | SELECT STATEMENT             |             |     2 |    92 |     4  (25)

| 00:00:01 |

|   1 |  NESTED LOOPS                |             |     2 |    92 |     4  (25)

| 00:00:01 |

|   2 |   SORT UNIQUE                |             |     2 |    52 |     2   (0)

| 00:00:01 |

|*  3 |    TABLE ACCESS FULL         | RESERVES    |     2 |    52 |     2   (0)

| 00:00:01 |

|   4 |   TABLE ACCESS BY INDEX ROWID| SAILORS     |     1 |    20 |     1   (0)

| 00:00:01 |

|*  5 |    INDEX UNIQUE SCAN         | SYS_C004050 |     1 |       |     0   (0)

| 00:00:01 |

————————————————————————————————————————

——————

Predicate Information (identified by operation id):
—————————————————————————-

   3 – filter(“R”.”DID”=1)
   5 – access(“R”.”SID”=”S”.”SID”)

Note
——-
   – dynamic sampling used for this statement

Statistics
—————————————————————————————
          8  recursive calls
          0  db block gets
         14  consistent gets
          0  physical reads
          0  redo size
        410  bytes sent via SQL*Net to client
        380  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          3  sorts (memory)
          0  sorts (disk)
          1  rows processed

This is the possible list of assignments for clp 1.

Sanket told to tell this to all it also has been displayed on google groups and facebook. Courtesy sanket.

This is the possible list of assignments for clp 1.
(VB oracle, procedure, trigger)
1. voting system for election
2. customer data system for bank mgmnt project
3online aptitude test mgmnt system
4. airline reservation system
5. result analysis system for students
6. User/admin moovie ticket system
7. medical shop system
8 emmployee info for an organisation & retrieving the data foran employee
9. library database mgmnt system
10.automobile mgmnt sytems
————————————————————————————————————————-

XML
1.travel agency system & xml dbase to retrieve data
2. Airline reservatio system ,DTD use, xml queries
—————————————————————————————————————————

C LANGUAGE
1.c program for mulitiple transactions on a bankiing system
2. decision tree for copmuter shop
————————————————————————————————————————-

DATA MINING
1. apriori data mining algorithm