264 CHAPTER 7 SIMPLEXML /* Retrieve text
264 CHAPTER 7 SIMPLEXML /* Retrieve text content for node from working template */ function getStoredValue($sxe, $arPath) { if ($sxe) { /* Loop through node path to find SimpleXML element from working template */ foreach($arPath AS $key=>$value) { $sxe = $sxe->$value; } return (string)$sxe; } return “”; } /* Set the text content for a node from working template */ function setValue($sxe, $field, $value) { if (is_array($value)) { /* Loop through node path to find SimpleXML element from working template */ foreach ($value AS $fieldname=>$fieldvalue) { setValue($sxe->$field, $fieldname, $fieldvalue); } } else { /* Encode the value to ensure content will be valid XML */ $sxe->$field = htmlentities($value); } } /* Validate fields in working template using the RegEx defined in specification */ function validatePAD($spec, $template) { $arRet = array(); foreach ($spec->Fields->Field as $field) { $arPath = explode(”/”, trim($field->Path)); array_shift($arPath); if ($arPath[0] != “MASTER_PAD_VERSION_INFO”) { $sxe = $template; $regex = “/”.trim($field->RegEx).”/”; foreach($arPath AS $key=>$value) { $sxe = $sxe->$value; if (! $sxe) { break; } } if ($sxe) { $value = (string)$sxe; if (! preg_match($regex, $value)) { /* Capture fields failing validation for later display */ $arRet[] = array($field->Title, $field->RegExDocumentation);
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Clan Web Hosting services