Home » Docs » FeedWriter » writeConstruct()

writeConstruct()

Internal function used to output an XML element based on a single construct from the FeedConstruct class.
Usage
writeConstruct( XMLWriter $writer , string[] $feedData , string[] $construct , string $feedCommonName ) Internal function used to output an XML element based on a single construct from the FeedConstruct class. writeConstruct() also manages child elements by including nested calls to output any child constructs/elements if found.

The "commonName" value in the construct passed to the function is used to find the matching data in the feed or feed items.
Parameters
XMLWriter $writer
The XMLWriter object being used to build the feed XML.
string[] $feedData
An array of strings, or a single string variable containing data from the feed that corresponds to the current construct being outputted by writeConstruct().
string[] $construct
An associating array of strings representing a single construct from the FeedConstruct class.
string $feedCommonName
A string containing the value of the "commonName" for the current construct, which should match a key in the array of feed data or feed item data.
Return Values
Examples
example use of writeConstruct(). Please note that this function has been written for internal use by the getXML() function of the FeedWriter class. Write the title element (feedTitle) of an Atom 1.0 feed:
//assumes XMLWriter object already created, document started, outer xml elements of feed complete, etc.

//Set the main feed construct to the Atom 1.0 format (sets the $phpFeedWriter->feed_construct variable to an instance of the FeedConstruct class for the Atom 1.0 format)
$phpFeedWriter->set_feedConstruct(Atom_1);
 
//Get the "feedTitle" construct using the FeedConstruct Class object (now stored in the $feed_construct variable of teh FeedWriter class)
$feedTitle_construct = $phpFeedWriter->feed_construct->getConstruct("feedTitle");

//Validate against the corresponding data in the first item of the feed (if the feed has items)
$phpFeedWriter->writeConstruct($writer, 'The title', $feedTitle_construct, $feedTitle_construct['commonName']);
Related Resources

Comments (0)

No comments yet

Leave a Reply

You must be logged in to post a comment.
  • Php FeedWriter (c) Copyright 2011 Daniel Soutter. Php FeedWriter and the information on this site has been designed to benefit website developers, owners and users, but may contain errors and is provided as is, with no warranty. Terms.