Cheap Web Hosting for Developers

PHP, MySQL, Java, Unix Cheap Web Hosting

264 CHAPTER 7 SIMPLEXML /* Retrieve text

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

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

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