Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us
Online Universities
Auto Insurance Quote
Promotional Products
Promotional Items
Baby Photo Contest
Domain registration
Corporate Gifts
Calling Cards
Prepaid Phone Card
PDA Phones & Cases
GPS
Laptops
Dental Insurance
Free Business Cards

Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers



Quality Management ROI Calculator - Focus on Test Automation
The Rational Quality Management ROI calculator is intended to give you an idea of what return you can garner from implementing our functional testing solutions. Our quality management solutions offer tools to develop a continuous process, powered by automation to govern software delivery. »

Gartner MarketScope: Application Quality Management Solutions, 1Q 08
This Gartner MarketScope provides guidance for enterprises seeking to purchase tools to manage risk and software quality. We focus on tools fit for large-scale enterprise use and that are ready out of the box to manage quality requirements and functional testing. »

Whitepaper: Tips for Writing Good Use Cases
Writing a good use case isnt easy, but, fortunately, our experience can be your guide. The concepts and principles assembled here represent the works of many people at IBM, and they form a foundation of proven best practices. »

Whitepaper: The Role of Integrated Requirements Management in Software Delivery
Learn about the critical role integrated requirements management can play in helping ensure your business goals and IT projects are continuously aligned-whether you are sourcing, integrat-ing, building or maintaining your software. It also looks at ways that integration and automation can help ensure managing projects and the required changes can be executed using manageable processes that satisfy stakeholders and development teams. »
Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

SAX Example Code Page 29

March 8, 2002


In the startElement function we define what HTML is associated with which element. The function startElement is called by the xml_set_element_handler function in the code. The startElement function must have three parameters:

  • $parser
    This parameter refers back to the instance of the xml parser that we create
  • $name
    This parameter refers to the name of the element in the XML document
  • $attribs
    This parameter refers to any Attributes in the Element.

In our sample XML we have <City>Cayo Coco</City> where <City> is the start element.

By default, the value of the element is case-folded, that is, it is converted to uppercase. We change the case folding a little further on in the code. If case folding is on, then the case statement will have the name in uppercase:

case "RECORDSET":

If case folding is turned on, the parser will not match the name of the element, i.e. Recordset does not match RECORDSET. This violates the XML 1.0 specification:

      function startElement($parser, $name, $attribs) 

      {

          global $currentTag, $currentAttribs;

          $currentTag = $name;

    

          $currentAttribs = $attribs;

          # define the HTML to use for the start tag.

          switch ($name) {

          case "Recordset":

              break;

    

          case "Travelpackage":

              while (list ($key, $value) = each ($attribs)) {

                  echo("<tr><td>$key: $value</td></tr>\n");

              }

              break;

 

          case "package":

              break;

 

          default:

              echo("<tr><td>$name</td><td>\n");

              break;

          }

      }

As the parser moves through the XML document it comes across elements. For example, the parser looks at the element <Travelpackage name="a"> and matches the element name with the appropriate case in the switch block. In this instance, the data should be displayed as a row in the table with a single cell containing the name and the value of each attribute within the <Travelpackage> tag. So, <tr><td>$key: $value</td></tr> is displayed.

The case statements for <Recordset> and <Package> are empty. Therefore, nothing will be displayed when the parser sees these tags. The default case displays <tr><td>$name</td><td> where $name is the name of the current element, like <City> or <Resort>. We could create a separate case for every element in the XML document, or use one common tag for all elements.

Now let us define what the XML will look like when it is parsed and displayed by the browser. It could display a list, in which case the default case would look something like:

default:

    echo("<li>$name</li>\n");

    break;


SAX Example Code Page 28
Professional PHP4 Programming
SAX Example Code Page 30


Up to => Home / Authoring / Languages / PHP / Pro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers