Suscriber with us



Receive HTML?

Syndicate

php-xml interview questionPart1 PDF Print E-mail

1.What is xml?

XML (eXtensible Markup Language) is a data format for structured document interchange on the Web.
It is a standard defined by The World Wide Web consortium (W3C).

XML doesn't define what data is being stored or the structure of that data.
XML simply defines tags and attributes for those tags. A properly formed XML tag looks like this:
<name>php xml</name>

2.An XML Pen list example

  <pens>
  <pen>
  <author>Rasmus</author>
  <title>PHP 5</title>
  <publisher>zend</publisher>
  </pen>
  <pen>
  <author>w3answers</author>
  <title>Project Management</title>
  <publisher>w3labs</publisher>
  </pen>
  </pens>

3.What are the Technology to Use for Parsing the XML

There are two types of XML parsers the we can use.

1. DOM (Document Object Module).
2. SAX (Simple API for XML).

DOM

The DOM (Document Object Model) extension allows to operate on XML documents through the DOM API with PHP 5. DOM  is a standard defined by the W3C for accessing XML documents.
In PHP 4, DOM xml extension is not following the  standard method names.

As per the  new W3C compatibility, the old domxml-based scripts won't work anymore. The API is quite different in PHP 5. But if we used the "almost W3C compatible" method names available in PHP 4.3, We only need to change the loading and saving methods, and remove the underscore in the method names. Other adjustments here and there may be necessary, but the main logic can stay the same. Though we have not used earlier so these will not be a problem for us.

The easiest way to read a well-formed XML file is to use the DOM library . The DOM library reads the entire XML document into an object  and represents it as a tree of nodes,

 SAX

SAX stands for Simple API for XML. It's a callback-based interface for parsing XML documents. SAX support has been available since PHP 3 and hasn't changed a lot since then. For PHP 5 the API is unchanged, The only difference is that it's not based on the expat library anymore, but on the libxml2 library.

Rather than treating an XML document as a tree-like structure, SAX treats it as a series of events such as startDocument or endElement. To accomplish this, a SAX appllication consists of a parser that sends these events to "handlers," methods or functions designated to handle them.





Digg!Del.icio.us!Google!Live!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Yahoo!Free social bookmarking plugins and extensions for Joomla! websites!
Last Updated ( Thursday, 13 March 2008 )
 

Download Utility

XAMPP
WAMP
EditPlus
Zend Studio

Polls

Which is the best Scripting language?