CHAPTER 7 SIMPLEXML 267 called on again
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:
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services