本文整理匯總了PHP中WebVista_Model_ORM::recurseXml方法的典型用法代碼示例。如果您正苦於以下問題:PHP WebVista_Model_ORM::recurseXml方法的具體用法?PHP WebVista_Model_ORM::recurseXml怎麽用?PHP WebVista_Model_ORM::recurseXml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WebVista_Model_ORM
的用法示例。
在下文中一共展示了WebVista_Model_ORM::recurseXml方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: recurseXml
public static function recurseXml($data, $rootNodeName = 'data', $xml = null)
{
if ($xml === null) {
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$rootNodeName} />");
}
// loop through the data passed in.
foreach ($data as $key => $value) {
if (is_object($data) && method_exists($data, "get_" . $key)) {
//$value = call_user_method("get",$data,$key);
$value = $data->get($key);
}
// no numeric keys in our xml please!
if (is_numeric($key)) {
// make string key...
//$key = "unknownNode_". (string) $key;
$key = "array";
}
// replace anything not alpha numeric
$key = preg_replace('/[^a-z_0-9]/i', '', $key);
// if there is another array found recrusively call this function
if (strpos($key, '_') === 0) {
} else {
if (is_array($value) || is_object($value)) {
$node = $xml->addChild($key);
// recrusive call.
WebVista_Model_ORM::recurseXml($value, $rootNodeName, $node);
} else {
// add single node.
if (is_resource($value)) {
$value = "resource";
}
$value = htmlentities(iconv("UTF-8", "ASCII//TRANSLIT", $value));
$xml->addChild($key, $value);
}
}
}
// pass back as string. or simple xml object if you want!
$xmlstr = $xml->asXML();
return preg_replace('/<\\?.*\\?>/', '', $xmlstr);
}
示例2: toXml
function toXml()
{
return WebVista_Model_ORM::recurseXml($this->_data, $this->systemName);
}