/**
  * @param DOMNode $node
  * @param ProxyObject $proxy
  */
 private function process(DOMNode $node, ProxyObject $proxy)
 {
     $proxy->setName($node->nodeName);
     if ($node->hasAttributes()) {
         for ($i = 0; $i < $node->attributes->length; $i++) {
             $attribute = $node->attributes->item($i);
             $proxy->set($attribute->name, $attribute->value);
         }
     }
     if ($node->hasChildNodes()) {
         $nodeTypes = array();
         foreach ($node->childNodes as $childNode) {
             if ($childNode->nodeName === '#text') {
                 $proxy->setValue($childNode->nodeValue);
             } else {
                 $childProxy = new ProxyObject();
                 $this->process($childNode, $childProxy);
                 $nodeTypes[$childProxy->getName()][] = $childProxy;
             }
         }
         foreach ($nodeTypes as $tagName => $nodes) {
             $proxy->set($tagName, $nodes);
         }
     }
 }
 /**
  * @param $data
  * @param ProxyObject $proxy
  */
 private function process($data, ProxyObject $proxy)
 {
     if (is_object($data)) {
         foreach ($data as $key => $value) {
             $childProxy = new ProxyObject();
             $this->process($value, $childProxy);
             $proxy->{$key} = $childProxy;
         }
     } elseif (is_array($data)) {
         $children = array();
         foreach ($data as $value) {
             $childProxy = new ProxyObject();
             $this->process($value, $childProxy);
             $children[] = $childProxy;
         }
         $proxy->setValue($children);
     } else {
         $proxy->setValue($data);
     }
 }