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

DevShed:
Inserting Comments and Accessing Nodes with the DOM XML Extension in PHP 5
Mar 11, 2008 @ 20:40:21

DevShed continues their series looking at using the DOM extension in PHP5 to work with XML in your application. They've already looked at adding attributes and creating CDATA information in a new DOM document. This time they build on that and also include new methods - appending comment nodes and getting at XML nodes by their IDs.

I'm talking about the DOM XML extension, which allows you to handle XML documents by using the DOM API. Thus, if you're interested in learning how to put this extension to work for you quickly, look no further, because you've come to the right place. [...] In this third installment of the series, I'll be teaching you specifically how to append comment nodes to a given XML string and how to extract certain elements via their IDs.

They review the method to add attributes and CDATA to an XML document first. Then they cover the other two new topics - appending comment nodes and grabbing nodes by their ID attribute.

tagged: dom extension php5 node cdata attribute id fetch tutorial

Link:

DevShed:
Working with Attributes and CDATA Sections with the DOM XML Extension
Mar 06, 2008 @ 00:29:00

DevShed has posted a new tutorial today that continues their series looking at XML handling with PHP. This time it's a focus on attributes in a CDATA section with DOM.

Since the DOM XML library comes equipped with many other methods that can be useful for adding custom attributes to the existing nodes of a given XML document, and creating new CDATA sections, among other things.

They start with a review of the DOM functionality to get you reacquainted. From there they move off into the createAttribute function and its use in the creation of CDATA elements in your XML.

tagged: dom extension tutorial createelement cdata section

Link:

David Coallier's Blog:
Quick Tip - PHP, SimpleXML and CDATA
Nov 06, 2007 @ 17:16:00

David Coallier has shared a quick tip today about the PHP/SimpleXML/CDATA combination and the creation of auto-generated classes.

I thought, hey I wonder how long it'd take in php.. so I was working on it and I actually couldn't remember all those funny extra parameters in simplexml_* so if you are googling and cannot find something that says exactly what you want well here it is.

His example includes two additional parameters in his simplexml_load_string call to handle the CDATA section correctly and make accessing the data inside the block just like getting at anything else in the object.

Note that Rob Richards has also commented on the post that this issue was corrected a while back and it shouldn't be needed anymore, but could effect older versions of the SimpleXML functionality.

tagged: simplexml cdata parameter extra simplexmlelement libxmlnocdata simplexml cdata parameter extra simplexmlelement libxmlnocdata

Link:

David Coallier's Blog:
Quick Tip - PHP, SimpleXML and CDATA
Nov 06, 2007 @ 17:16:00

David Coallier has shared a quick tip today about the PHP/SimpleXML/CDATA combination and the creation of auto-generated classes.

I thought, hey I wonder how long it'd take in php.. so I was working on it and I actually couldn't remember all those funny extra parameters in simplexml_* so if you are googling and cannot find something that says exactly what you want well here it is.

His example includes two additional parameters in his simplexml_load_string call to handle the CDATA section correctly and make accessing the data inside the block just like getting at anything else in the object.

Note that Rob Richards has also commented on the post that this issue was corrected a while back and it shouldn't be needed anymore, but could effect older versions of the SimpleXML functionality.

tagged: simplexml cdata parameter extra simplexmlelement libxmlnocdata simplexml cdata parameter extra simplexmlelement libxmlnocdata

Link:

Stuart Herbert's Blog:
Using SimpleXML To Parse RSS Feeds
Jan 11, 2007 @ 15:48:00

In PHP5, SimpleXML reigns as king when you just need a quick, light, easy way to pull in the data from an XML feed, especially RSS feeds. Stuart Herbert found this out and is sharing his knowledge in a new post to his blog showing how he worked with SimpleXML and namespaces to combine feeds into a "multi-blog".

I can fake the multiblog by putting several different blogs on the site, and generating a homepage from the RSS feeds of the individual blogs. Should be simple enough, and it sounds like the perfect nail to hit with the SimpleXML hammer of PHP 5 :) Funnily enough, in work last week we were wondering whether you could use SimpleXML with XML namespaces (alas, we still use PHP 4 at work atm), so armed with the perfect excuse, I set to work.

He follows the path he took - pulling in the feeds, using the information inside the SimpleXML element. The tricky part came in when he introduced the namespaces into the SimpleXML imports. He shows how to work with it rather than against it by using an array of namespace values and use the CDTA blocks in the results. The post wraps up with a full code listing of this handy little application.

tagged: xml parse rss simplexml namespace cdata xml parse rss simplexml namespace cdata

Link:

Stuart Herbert's Blog:
Using SimpleXML To Parse RSS Feeds
Jan 11, 2007 @ 15:48:00

In PHP5, SimpleXML reigns as king when you just need a quick, light, easy way to pull in the data from an XML feed, especially RSS feeds. Stuart Herbert found this out and is sharing his knowledge in a new post to his blog showing how he worked with SimpleXML and namespaces to combine feeds into a "multi-blog".

I can fake the multiblog by putting several different blogs on the site, and generating a homepage from the RSS feeds of the individual blogs. Should be simple enough, and it sounds like the perfect nail to hit with the SimpleXML hammer of PHP 5 :) Funnily enough, in work last week we were wondering whether you could use SimpleXML with XML namespaces (alas, we still use PHP 4 at work atm), so armed with the perfect excuse, I set to work.

He follows the path he took - pulling in the feeds, using the information inside the SimpleXML element. The tricky part came in when he introduced the namespaces into the SimpleXML imports. He shows how to work with it rather than against it by using an array of namespace values and use the CDTA blocks in the results. The post wraps up with a full code listing of this handy little application.

tagged: xml parse rss simplexml namespace cdata xml parse rss simplexml namespace cdata

Link:

Builder.com:
Dynamic XML document construction with the PHP DOM
Dec 11, 2006 @ 17:05:00

Builder.com as posted a quick tutorial on working with the DOM functionality in PHP to create a dynamic XML document (Doctype and all).

Over the course of this article, I'll be introducing you to the main functions in this API, showing you how to programmatically generate a complete well-formed XML document from scratch and save it to disk.

They start off with creating the Doctype declaration before actually adding the content into the file (elements and text nodes), adding some attributes to the nodes, putting CDATA blocks inside them, and pushing out the results on the other side to be saved to a local "order.xml" file.

You can also download this article if you'd like to work with it (and its included PHP files) on your own.

tagged: xml dom dynamic document create attribute node doctype cdata xml dom dynamic document create attribute node doctype cdata

Link:

Builder.com:
Dynamic XML document construction with the PHP DOM
Dec 11, 2006 @ 17:05:00

Builder.com as posted a quick tutorial on working with the DOM functionality in PHP to create a dynamic XML document (Doctype and all).

Over the course of this article, I'll be introducing you to the main functions in this API, showing you how to programmatically generate a complete well-formed XML document from scratch and save it to disk.

They start off with creating the Doctype declaration before actually adding the content into the file (elements and text nodes), adding some attributes to the nodes, putting CDATA blocks inside them, and pushing out the results on the other side to be saved to a local "order.xml" file.

You can also download this article if you'd like to work with it (and its included PHP files) on your own.

tagged: xml dom dynamic document create attribute node doctype cdata xml dom dynamic document create attribute node doctype cdata

Link:


Trending Topics: