public function FrxRenderer::xmlToValues in Forena Reports 7.4
Convert XML to key value pairs. This is used in support of graping to get specific key/value pairs in an array format suitable for passing off to php libraries.
Parameters
unknown $path:
unknown $data_path:
string $label_path:
string $pairs:
Return value
multitype:multitype:number Ambigous <unknown_type, text, mixed, string, unknown>
File
- renderers/
FrxRenderer.inc, line 854 - FrxRenderer.inc Base class for Frx custom renderers @author davidmetzler
Class
- FrxRenderer
- @file FrxRenderer.inc Base class for Frx custom renderers @author davidmetzler
Code
public function xmlToValues($path, $data_path, $label_path = '', $pairs = FALSE) {
$do = Frx::Data();
$data = $do
->currentContext();
$values = array();
if (is_object($data)) {
$nodes = $data
->xpath($path);
if ($nodes) {
foreach ($nodes as $i => $node) {
$do
->push($node, $this->id);
$val = $this->teng
->replace($data_path, TRUE);
if ($label_path) {
$key = strip_tags($this->teng
->replace($label_path, FALSE));
}
else {
$key = $i;
}
if ($pairs && $label_path) {
$values[] = array(
floatval($key),
floatval($val),
);
}
else {
$values[$key] = $val;
}
$do
->pop();
}
}
}
return $values;
}