Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


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















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

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


SML

March 1, 2002


Some developers prefer to use the Simplified Markup Language (SML) format when writing XML. SML is a subset of XML that simplifies an XML document. SML (also know as Minimal XML or Simplified XML) greatly simplifies the structure of an XML document by removing many parts of an XML document. SML is XML without:

  • Attributes
  • CDATA sections
  • Comments
  • Document Type Declarations
  • Empty element tags
  • Entity references
  • Mixed contents
  • Predefined entities
  • Processing instructions
  • Prolog
  • XML declaration

More information on SML can be found at: http://www.docuverse.com/smldev/minxml.html.

Converting XML into SML

The XML document, sample.xml, contains multiple data types, elements with attributes, and four levels of nested elements. In this sample document the second element, , has an attribute of name. The value of the attribute is Cuba. The element supports multiple attributes:

<?xml version="1.0"?>
<!DOCTYPE Travelpackages SYSTEM "sample.dtd">
<Travelpackages>
  <Country name="Cuba">
    <City name="Cayo Coco">
      <Resort name="Club Tryp Cayo Coco" rating="4" typeofholiday="beach" 
              watersports="true" meals="true" drinks="true">
        <Package dateofdep="5/8/98" price="879"/>
        <Package dateofdep="5/1/98" price="879"/>
      </Resort>
    </City>
    <City name="Varadero ">
      <Resort name="Sol Club Paleras" rating="3" typeofholiday="beach" 
              watersports="false" meals="true" drinks="false">
        <Package dateofdep="5/30/98" price="799"/>
        <Package dateofdep="5/23/98" price="879"/>
        <Package dateofdep="5/16/98" price="889"/>
      </Resort>
    </City>
  </Country>
</Travelpackages>

To convert this XML to SML format, the attributes should be changed to elements. Let's take a look at the sample.xml document in SML format:

<Travelpackages>
  <Country>
    <Country_name>Cuba</Country_name>
    <City>
      <City_name>Cayo Coco</City_name>
      <Resort>
        <Resort_name>Club Tryp Cayo Coco</Resort_name>
        <Resort_rating>4</Resort_rating>
        <Resort_typeofholiday>beach</Resort_typeofholiday>
        <Resort_watersports>true</Resort_watersports>
        <Resort_meals>true</Resort_meals>
        <Resort_drinks>true</Resort_drinks>
        <Package>
          <Package_dateofdep>5/8/98</Package_dateofdep>
          <Package_price>879</Package_price>
        </Package> 
        <Package>
          <Package_dateofdep>5/1/98</Package_dateofdep>
          <Package_price>879</Package_price>
        </Package>
      </Resort>
    </City>
  </Country>
</Travelpackages>


<b>In XML white space is ignored unless you explicitly preserve it.</b>

This sample XML document while short is sufficiently complex to show the differences in how the different APIs handle XML. This sample has most of the characteristics that we will find in most XML documents. We will change the XML format a little bit when dealing with the different APIs so we can get the code to work. You'll need to remember to check your XML to ensure that it works with the API that you choose.

PHP and XML

PHP allows support for four ways to interact with an XML document. They are:

  • Simple API for XML (SAX)
  • Document Object Model API (DOM)
  • PHP Recordset API for XML (PRAX)
  • Sablotron (XSLT)

Each API interacts with the same XML data in different ways, and all three support or don't support slightly different parts of XML.

The XML Framework
Professional PHP4 Programming
Verifying XML Support


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, & Permissions, Privacy Policy.

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