Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Evert Pot:
An XML library for PHP you may not hate.
Apr 02, 2015 @ 16:13:55

Evert Pot has posted about an XML library you may not hate, the sabre/xml library.

If you are writing or consuming API's in PHP, chances are that you need to work with XML. In some cases you may even prefer it. You may have started with SimpleXML and after a while switched to using the DOM after realizing SimpleXML is really not that simple if you strictly use xml namespaces everywhere.

For writing XML, you may have found that using the DOM requires far too much code, or you may simply generate your XML by echoing strings, knowing that it may not be the best idea. sabre/xml hopes to solve your issues, by wrapping XMLReader and XMLWriter, and providing standard design patterns.

He includes some example code showing how it works, extending the XMLReader/Writer functionality with a simplified interface. He includes examples of both writing a new XML file or reading in and working with the contents of a given one. He does point out one issue, though - the library cannot really read in XML contents, modify it and send it back out (it's a "single pass" system). He wraps up the post talking about the various interfaces and elements in the library and some of the overall benefits it provides.

tagged: xml library xmlreader xmlwriter interface simple

Link: http://evertpot.com/an-xml-library-you-may-not-hate/

DZone.com:
Guidelines for generating XML
Jul 15, 2010 @ 16:50:44

On DZone.com there's a recent post from Evert Pot talking about some guidelines for generating XML including a brief PHP example.

Over the last little while I've come across quite a few XML feed generators written in PHP, with varying degrees of 'correctness'. Even though generating XML should be very simple, there's still quite a bit of pitfalls I feel every PHP or (insert your language)-developer should know about.

His suggestions for better XML include:

  • You are better off using an XML library (like xmlwriter)
  • Understand Unicode
  • CDATA is never a solution
  • Be verbose
  • Be careful with entities
tagged: guideline generate xml xmlwriter suggestion

Link:

PHPBuilder.com:
A Quick PHP XMLWriter Class Tutorial: XML & RSS
Jan 19, 2009 @ 17:19:52

The PHPBuilder.com has posted today looking to introduce you to a powerful XML creation tool in PHP5 installations - XMLWriter.

They jump right in and show it in action by creating a simple RSS document with one element inside. A call to the flush() method on your XMLWriter object is all it takes to output the XML.

They also change things up and bit and swap out the procedural code for a more object-oriented approach with a constructor that sets up the object and adds in some of the common RSS information. Their addItem() method is called to add in a sample item (in this case, an entry for a CD player product) and _endRSS() closes things off and runs that flush() to send it all back out.

You can find out more about XMLWriter (and its sister, XMLReader) in the PHP manual.

tagged: xmlwriter tutorial rss class oop php5 xmlreader

Link:

Zend Developer Zone:
XML and PHP 5
Aug 01, 2007 @ 15:13:00

The Zend Developer Zone has a new tutorial posted looking at PHP5 and the new XML tools that it has to offer - as broken up into categories:

Things are a bit different using XML in PHP 5. In a similar scenario, you could use one of the new native extensions, like DOM or SimpleXML, to manipulate the XML data tree. This tree can then be passed directly to and used by the XSL extension without incurring any additional overhead. There is no serialization nor copying involved; ext/xsl is able to work directly with the XML tree it is given, resulting in a significant improvement in use of system resources as compared to coding a similar task in PHP 4. So now that you have an idea why XML support got a face lift, you might like to know about the different tools available to you.
tagged: xml php5 tutorial introduction dom xsl xmlreader xmlwriter simplexml xml php5 tutorial introduction dom xsl xmlreader xmlwriter simplexml

Link:

Zend Developer Zone:
XML and PHP 5
Aug 01, 2007 @ 15:13:00

The Zend Developer Zone has a new tutorial posted looking at PHP5 and the new XML tools that it has to offer - as broken up into categories:

Things are a bit different using XML in PHP 5. In a similar scenario, you could use one of the new native extensions, like DOM or SimpleXML, to manipulate the XML data tree. This tree can then be passed directly to and used by the XSL extension without incurring any additional overhead. There is no serialization nor copying involved; ext/xsl is able to work directly with the XML tree it is given, resulting in a significant improvement in use of system resources as compared to coding a similar task in PHP 4. So now that you have an idea why XML support got a face lift, you might like to know about the different tools available to you.
tagged: xml php5 tutorial introduction dom xsl xmlreader xmlwriter simplexml xml php5 tutorial introduction dom xsl xmlreader xmlwriter simplexml

Link:

Community News:
Livedocs XMLWriter Entry Updated
Jan 03, 2007 @ 22:55:00

As mentioned briefly by Pierre-Alain Joye, the documentation (on the Livedocs website) has been updated for the XMLWriter package.

This is the XMLWriter extension. It wraps the libxml xmlWriter API.

This extension represents a writer that provides a non-cached, forward-only means of generating streams or files containing XML data. This extension can be used in an object oriented style or a procedural one. Every method documented describes the alternative procedural call.

The updated documentation cn be found here.

tagged: livedocs xmlwriter extension update livedocs xmlwriter extension update

Link:

Community News:
Livedocs XMLWriter Entry Updated
Jan 03, 2007 @ 22:55:00

As mentioned briefly by Pierre-Alain Joye, the documentation (on the Livedocs website) has been updated for the XMLWriter package.

This is the XMLWriter extension. It wraps the libxml xmlWriter API.

This extension represents a writer that provides a non-cached, forward-only means of generating streams or files containing XML data. This extension can be used in an object oriented style or a procedural one. Every method documented describes the alternative procedural call.

The updated documentation cn be found here.

tagged: livedocs xmlwriter extension update livedocs xmlwriter extension update

Link:

Pierre's Blog:
XMLWriter in PHP 5.1.2
Dec 07, 2005 @ 13:35:02

From Pierre today, there's this quick post concerning the inclusion of XMLWriter in PHP 5.1.2.

XMLWriter is finally bundled in php5. It will available and enabled by default in the next PHP release (5.1.2).

With XMLReader, XMLWriter is a really nice addition to the xml extensions.

The XMLWriter extension provides fast, non-cached, forward-only means of generating streams or files containing XML data.

tagged: xmlwriter 5.1.2 included xmlwriter 5.1.2 included

Link:

Pierre's Blog:
XMLWriter in PHP 5.1.2
Dec 07, 2005 @ 13:35:02

From Pierre today, there's this quick post concerning the inclusion of XMLWriter in PHP 5.1.2.

XMLWriter is finally bundled in php5. It will available and enabled by default in the next PHP release (5.1.2).

With XMLReader, XMLWriter is a really nice addition to the xml extensions.

The XMLWriter extension provides fast, non-cached, forward-only means of generating streams or files containing XML data.

tagged: xmlwriter 5.1.2 included xmlwriter 5.1.2 included

Link:


Trending Topics: