/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codehighlighterimpl/DomExample1.php

  • Committer: galaxyAbstractor
  • Date: 2013-04-10 15:49:32 UTC
  • mto: (19.1.5 lenasys)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: galaxyabstractor@gmail.com-20130410154932-4vizlzk0ar5gykvi
* Added an simple admin panel to the codeviewer-cmssy stuff
* Redesigned a bit like the mockups - still stuff to come
* Implemented the codeviewer + admin panel again using the Framework CodeIgniter instead 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
<span class="description">
3
 
<br>
4
 
<div class="descriptionheading">Overview</div>
5
 
This example shows how to navigate a DOM document.
6
 
<br><br>
7
 
<div class="descriptionheading">Initiation</div>
8
 
The first part of the code (rows 8-10) creates the DOM document object. The DOM object has all the functionality needed to 
9
 
load and parse a document. We use the load function (row 10) to load the data into memory. When this is done, the DOM object contains
10
 
a reference to the data that has been loaded into memory. <a href="#" onclick="highlight(['ace_showcodephp'],'str_replace')">str_replace</a>
11
 
<br><br>
12
 
<div class="descriptionheading">Element Navigation</div>
13
 
The <span class="interestingdescription">documentElement</span> (row 12) attribute of the DOMDocument object contains a reference
14
 
to the root node of the dom document. In this case it is a person element. <a href="#" onclick="highlight(['ace_showcodephp'],'buffer')">buffer</a>
15
 
<br><br>
16
 
In the following row (row 12) we print the name of the element using the <span class="interestingdescription">tagName</span> attribute (for this file <a href='../XMLData/example1.xml'>example1.xml</a> the root element is a person element)  <a href="#" onclick="highlight(['ace_showcodephp','ace_indexphp'],'script');">script</a>
17
 
<br><br>
18
 
<?php   showfile("js.txt", "javascript");?>
19
 
The foreach statement on row (13-17) iterates over the <span class="interestingdescription">childNodes</span> of the root node that was retrieved on row 12.
20
 
The childNodes attribute returns an array of the child nodes of the node. If there are no child nodes, an empty array is returned. <a href="#" onclick="highlightrows(['ace_showcodephp'],0, 5)">str_replace</a>
21
 
<br><br>
22
 
The <span class="interestingdescription">nodeValue</span> attribute (row 16) of a document element gives us the text content of any elements
23
 
below the referenced element. In this case the nodeValue for the "car" element returns  the value "Red!!" even though the contents inside the car element 
24
 
is a color element which contains the text "Red!!".
25
 
<br><br>
26
 
<div class='exampleheading'>Web Page Output:<br><br>
27
 
<img src='DomExample1.png'>
28
 
</div>
29
 
                                                                                                                                        
30
 
</span>
 
 
b'\\ No newline at end of file'