PHP5 offers the developer a lot more muscle to work with XML. New and modified extensions such as the DOM, SimpleXML, and XSL make working with XML less code intensive. In PHP5, the DOM is compliant with the W3C standard. Most importantly, the interoperability among these extensions is significant, providing additional functionality, like swapping formats to extend usability, W3C's XPath, and more, across the board. Here you will look at input and output options, and you will depend on the Yahoo Web Services REST protocol interface to provide a more sophisticated showcase for the functionality of the now familiar DOM and SimpleXML extensions and conclude with the XSL extension.
XML in PHP5
Extensible Markup Language (XML), described as both a markup language and a text-based data storage format, offers a text-based means to apply and describe a tree-based structure to information. Here you'll look at XML in the context of Web services, probably one of the most important factors driving the recent growth of XML outside the enterprise world.In PHP5, there are totally new and entirely rewritten extensions for manipulating XML, all based on the same libxml2 code. This common base provides interoperability between these extensions that extends the functionality of each. The tree-based parsers include SimpleXML, the DOM, and the XSLT processor. If you are familiar with the DOM from other languages, you will have an easier time coding with similar functionality in PHP than before. The stream-based parsers include the Simple API for XML (SAX) and XMLReader. SAX functions the same way it did in PHP4.You can use to manipulate an XML file. Using the DOM is efficient only when the XML file is relatively small. The advantages to using this method are the solid standard of the familiar W3C DOM, its methods, and the flexibility it brings to coding. The disadvantages of the DOM are the difficulty in coding and performance issues with large documents.
The SimpleXML extension is a tool of choice for manipulating an XML document, provided that the XML document isn't too complicated or too deep, and contains no mixed content. SimpleXML is easier to code than the DOM, as its name implies. It is far more intuitive if you work with a known document structure. Greatly increasing the flexibility of the DOM and SimpleXML the interoperative nature of the libXML2 architecture allows imports to swap formats from DOM to SimpleXML and back at will.
XML in PHP5
Extensible Markup Language (XML), described as both a markup language and a text-based data storage format, offers a text-based means to apply and describe a tree-based structure to information. Here you'll look at XML in the context of Web services, probably one of the most important factors driving the recent growth of XML outside the enterprise world.In PHP5, there are totally new and entirely rewritten extensions for manipulating XML, all based on the same libxml2 code. This common base provides interoperability between these extensions that extends the functionality of each. The tree-based parsers include SimpleXML, the DOM, and the XSLT processor. If you are familiar with the DOM from other languages, you will have an easier time coding with similar functionality in PHP than before. The stream-based parsers include the Simple API for XML (SAX) and XMLReader. SAX functions the same way it did in PHP4.You can use to manipulate an XML file. Using the DOM is efficient only when the XML file is relatively small. The advantages to using this method are the solid standard of the familiar W3C DOM, its methods, and the flexibility it brings to coding. The disadvantages of the DOM are the difficulty in coding and performance issues with large documents.
The SimpleXML extension is a tool of choice for manipulating an XML document, provided that the XML document isn't too complicated or too deep, and contains no mixed content. SimpleXML is easier to code than the DOM, as its name implies. It is far more intuitive if you work with a known document structure. Greatly increasing the flexibility of the DOM and SimpleXML the interoperative nature of the libXML2 architecture allows imports to swap formats from DOM to SimpleXML and back at will.
An interesting application of XSL is to create XML files on the fly to contain whatever data has just been selected from the database. Using this technique, it is possible to create complete Web applications where the PHP scripts are made up of XML files from database queries, then use XSL transformations to generate the actual HTML documents. This method completely splits the presentation layer from the business layer so that you can maintain either of these layers independently of the other.
No comments:
Post a Comment