Introduction to Zend Framework

 Learning Zend Framework


 Zend Framework Reference

  •  Zend_Gdata
  •  Zend_Http
  •  Zend_InfoCard
  •  Zend_Json
  •  Zend_Layout
  •  Zend_Ldap
  •  Zend_Loader
  •  Zend_Locale
  •  Zend_Log
  •  Zend_Mail
  •  Zend_Markup
  •  Zend_Measure
  •  Zend_Memory
  •  Zend_Mime
  •  Zend_Navigation
  •  Zend_Oauth
  •  Zend_OpenId
  •  Zend_Paginator
  •  Zend_Pdf
  •  Zend_ProgressBar
  •  Zend_Queue
  •  Zend_Reflection
  •  Zend_Registry
  •  Zend_Rest

  •  Zend_Search_Lucene
  •  Zend_Serializer
  •  Zend_Server
  •  Zend_Service
  •  Zend_Session
  •  Zend_Soap
  •  Zend_Tag
  •  Zend_Test
  •  Zend_Text
  •  Zend_TimeSync
  •  Zend_Tool
  •  Zend_Tool_Framework
  •  Zend_Tool_Project
  •  Zend_Translate
  •  Zend_Uri
  •  Zend_Validate
  •  Zend_Version
  •  Zend_View
  •  Zend_Wildfire
  •  Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Update 2011-11-16 - Revision 24438 - Version ZF 1.11.x

    32.7. Modifying Feed and Entry structures

    Zend_Feed's natural syntax extends to constructing and modifying feeds and entries as well as reading them. You can easily turn your new or modified objects back into well-formed XML for saving to a file or sending to a server.

    Example 32.5. Modifying an Existing Feed Entry

    $feed = new Zend_Feed_Atom('');
    $entry $feed->current();

    $entry->title 'This is a new title';
    $entry->author->email '';


    This will output a full (includes <?xml ... > prologue) XML representation of the new entry, including any necessary XML namespaces.

    Note that the above will work even if the existing entry does not already have an author tag. You can use as many levels of -> access as you like before getting to an assignment; all of the intervening levels will be created for you automatically if necessary.

    If you want to use a namespace other than atom:, rss:, or osrss: in your entry, you need to register the namespace with Zend_Feed using Zend_Feed::registerNamespace(). When you are modifying an existing element, it will always maintain its original namespace. When adding a new element, it will go into the default namespace if you do not explicitly specify another namespace.

    Example 32.6. Creating an Atom Entry with Elements of Custom Namespaces

    $entry = new Zend_Feed_Entry_Atom();
    // id is always assigned by the server in Atom
    $entry->title 'my custom entry';
    $entry->author->name 'Example Author';
    $entry->author->email '';

    // Now do the custom part.

    $entry->{'myns:myelement_one'} = 'my first custom value';
    $entry->{'myns:container_elt'}->part1 'first nested custom part';
    $entry->{'myns:container_elt'}->part2 'second nested custom part';


    digg delicious meneame google twitter technorati facebook