Constructing unsupported XML elements using the PHP client library


When a new XML element is introduced, client library support needs to be added. At times, the services move a bit faster than the client libraries. This means that (as per the AtomPub spec) clients must store all unknown elements returned from the server. Clients may also wish to be able to use new functionality which isn't explicitly supported yet in the libraries, so clients can allow you to create arbitrary XML elements and attach them to entries.

The PHP client library accomplishes this using extension elements, represented as instances of Zend_Gdata_App_Extension_Element. Each time the server returns an element that is unknown to the client library, the client creates an instance of that class and stores it in the extensionElements array of the class representing the parent element. In order to send arbitrary XML, you can also construct a new Zend_Gdata_App_Extension_Element and place it in the extensionElements array.

As an example, Google Base added a publishing priority option, specified by adding a <gm:publishing_priority> element. At the time of this post, the element isn't supported by a class in the PHP client library, so here's how you can add it.

<?php
require_once 'Zend/Gdata/Gbase.php';
require_once 'Zend/Gdata/App/Extension/Element.php';

$base = new Zend_Gdata_Gbase();
$entry = $base->newItemEntry();

// Constructing a Zend_Gdata_App_Extension_Control
$control = $base->newControl(); 

// Constructing the extension element, and placing it into the array
// of extension owned by the class representing the parent app:control element.
// Arguments: 
//   element name (including prefix)
//   namespace prefix
//   namespace URI
//   text node of the new element
$control->extensionElements = array(
  new Zend_Gdata_App_Extension_Element('gm:publishing_priority', 'gm', 'http://base.google.com/ns-metadata/1.0', 'high')
);
$entry->control = $control;

Of course, if you discover missing elements, please feel free to file an issue in the Zend Framework issue tracker and, since it's open source, you can also contribute a fix back to the project. More information on contributing can be found on the Zend Framework wiki.

16 comments:

thanh tung said...

Girl Xinh | Hot Girl | Cute Girl | Sexy Girl | Hot Girl Asian
Hot Girl | Lexi Belle | Sexy Girl | Cute Girl | Hot Asian Girl | Leah Dizon | Hot Girl Asian | Girl Xinh
socks proxy | socks5 | proxy free |proxy list

uknowme said...

Of course, if you discover missing elements, please feel free to file an issue in the Zend Framework issue tracker and, since it's open source, you can also contribute a fix back to the project. More information on contributing can be found on the
t-shirt-world

4Life

Unknown said...

Codigo de sim

cmtech said...

This article is great for me. I will share it with my friends. Thank you
cổng xoay

Unknown said...

How to as per the spec store all unknown elements returned from the server.
báo giá cửa cuốn
giá cửa cuốn
cửa cuốn giá rẻ
cửa lùa gỗ

Best Travel Portal Development said...

Hoppa Transfer is the no 1 specialist in smooth, reliable transfers, serving over 700 airports and 7500 cities and resorts.TeamIndia Webdesign provide the best hoppa transfers API Integration through XML with fast request response.For more information just visit our website

Ethan jurk said...

what a lovely post !!

Connect Canon Printer To Wireless Network

augustwalker said...

hp laserjet p1102w wireless setup-printer on various gadgets on MAC, Windows & Without CD as all realize its gives you quick, simple and moderate printing.

Jatin Sethi said...

Drug abusers are crazy. Drug abusers need assistance to get the opportunity to detox and rehab. So for what reason do relatives trust that their friends and family will take themselves to rehab
motivational quotes for addicts
quotes for recovering addicts

Aliza Kate said...

If you want to download and install windows essentials on windows 10 than learn step by step process to install how to download tools including movie maker.
https://promptresolve.com/operating-system/download-windows-essentials-windows-10/

Dim4ksan said...

All my conscious life I suffered a lot when we were given essays for homework, because I was not very good at it. My classmate advised me a great service like essaypro. After a very easy registration, I made my order to write an essay. I was pleasantly surprised by the staff of this service, everything happens very quickly, the order is processed almost immediately. My order was ready in about an hour and a half. I recommend this service to those who want to save time and get a good score.

Dim4ksan said...

It's a great way to find your dream gal, on the one hand. In addition to meeting many delighted find a russian bride, you will also discover stunning Russian architecture and beautiful landscapes. But this approach has its own difficulties. First, for at least one week in Russia you would have to pay a lot of money. Secondly, after a few dates, the women you date will never agree to move to your country. It's just what you need if you want to stop such difficult Russian brides.

kalamena said...

Do authentic latin wives really work, I wondered? Yes, brides are very genuine in mail order. Millions of women worldwide are committed to finding a foreign man. Their motives may be different. Some people wish to escape their homeland's poverty. Others are dissatisfied with the way local guys treat them. Many foreign brides are just beautiful to Western guys and really wish to marry one. What these ladies share is that they choose to become brides in the mail order. This trustworthy website helps you choose the appropriate company. This mail order.

Printer Repair City said...

Amazing, learn how to resolve Canon Printer Error u052 and solve canon printer error 6a81 Also canon printer error 5200 and this is good Canon Printer Error Code 1007 find out canon printer error e04 as well as canon printer error code p22

Tommy(R) said...

I went to the sea for a summer vacation, and in college I worked. The Rector then contacted me to have 10 online classes or I would be blackmailed from my position. Honestly, I wouldn't spoil my holiday. So I went to the webpage for help, where I requested take my class for me. The service was paid yet a minor sum was still paid. Finally, the rector awarded me a bonus after courses, and I stayed in black. This site, I really suggest.

Expert Market Research said...

The Methyl Isobutyl Ketone Market is expected to register a CAGR of more than 6% during the forecast period. In the automotive sector, methyl isobutyl ketone (MIBK) is used for manufacturing automotive chemicals, such as protective paints and coatings, that are further used in exterior parts of the vehicle, to add a pleasant appeal to vehicles. They are also used in metallic parts and plastic vehicle components of both interior and exterior types. Over a period, various companies have produced different and new variants in coatings, such as heat and anti-reflective coating, electro-chromatic and smart coatings for windows, self-cleaning topcoats, UV curable, powder coating system, iridescent and colour-changing base coat, and abrasion-resistant coatings for headlamps, among others.