Cheap Web Hosting for Developers

PHP, MySQL, Java, Unix Cheap Web Hosting

CHAPTER 7 SIMPLEXML 267 called on again

Filed under: PHP and XML — webmaster @ 19:29

CHAPTER 7 SIMPLEXML 267 called on again to load the empty template created by the DOM extension. This is performed only once when the application begins because the template is then passed in $_POST[’ptemplate’]. Being XML data, it is Base64-encoded within the form and Base64decoded before being used. The function printDisplay() takes three parameters. The first is the SimpleXMLElement containing the specification file. The second is the SimpleXMLElement containing the working template. The last parameter is a Boolean used for state. When in a preview state, the system generates display data only; otherwise, it displays editable fields. Being a standardized format, the application loops through the ->Fields->Field elements assuming they always exist. The Field element contains all the information for each node in the template document, including its location in the tree, which is stored in the Path child element. The Path, taking the form of a string such as XML_DIZ_INFO/Company_Info/Company_Name, is split into an array based on the /character, and the first element is removed. You do not need this element because it is the document element, which is already represented by the SimpleXMLElement holding the specification document. The first element breaks the display output into sections on the screen, skipping all fields that contain the node MASTER_PAD_VERSION_INFO. The information for this node and its children is already provided within the template file. The application then generates the appropriate input tags or displays content based on the state of the application. When input fields are generated, the name of the field corresponds to the location of the element within the document. For example, if you used XML_DIZ_INFO/Company_Info/Company_Name as the Path, the name within the form would be Company_Info[Company_Name]. Values for the fields are pulled from the getStoredValue() function. This is where it gets interesting with SimpleXML usage. The array containing the elements of the path is iterated. Each time, the variable $sxe, which originally contained the working template, is changed to be the child element of its current element using the $value variable, which is the name of the subnode. Examining a path from the specification file, such as XML_DIZ_INFO/Company_Info/Company_Name, the corresponding array, after removing the first element, would be array(’Company_Info’, ‘Company_Name’). This corresponds to the following XML fragment: Iterating through the array and setting $sxeeach time are the equivalent of manually coding this: $sxe = $sxe->Company_Info; $sxe = $sxe->Company_Name; You can navigate to the correct node using the information from the specification file without needing to know the document structure of the template file. Once iteration of the foreach is finished, the variable $sxeis cast to a string, which is the text content of the node the application is looking for, and is then returned to the application. When the data is submitted from the UI to the application, the function setValue() is called. As you probably recall, the name of the input fields indicate arrays, such as Company_Info[Company_Name]. No other named fields that are arrays are used in the

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Cheap Web Hosting