Пример #1
0
 /**
  * [toXmlNode description]
  * @param  [type] $parent [description]
  * @return [type]         [description]
  */
 public function attachNodeTo($parent)
 {
     if ($this->cdata && !preg_match("#^<!\\[CDATA#is", $this->value)) {
         $this->value = "<![CDATA[{$this->value}]]>";
     }
     $parent->addChild($this->name, '', $this->_namespace);
     $parent->{$this->name} = $this->value;
 }
/**
 *  Generates an XML block that conforms to the
 *  same format as the status XML returned by the
 *  previous MyEMSL backend
 *
 *  @param [type] $data     [description]
 *  @param [type] $xml_data [description]
 *
 *  @return [type]   [description]
 *
 *  @author Ken Auberry <*****@*****.**>
 */
function array_to_xml($data, &$xml_data)
{
    foreach ($data as $key => $value) {
        if (is_array($value)) {
            if (is_numeric($key)) {
                $key = 'item' . $key;
                //dealing with <0/>..<n/> issues
            }
            $subnode = $xml_data->addChild($key);
            array_to_xml($value, $subnode);
        } else {
            $xml_data->addChild("{$key}", htmlspecialchars("{$value}"));
        }
    }
}