/** * @param ProtocolNode $node */ protected function writeInternal($node) { $len = 1; if ($node->getAttributes() != null) { $len += count($node->getAttributes()) * 2; } if (count($node->getChildren()) > 0) { $len += 1; } if (strlen($node->getData()) > 0) { $len += 1; } $this->writeListStart($len); $this->writeString($node->getTag()); $this->writeAttributes($node->getAttributes()); if (strlen($node->getData()) > 0) { $this->writeBytes($node->getData()); } if ($node->getChildren()) { $this->writeListStart(count($node->getChildren())); foreach ($node->getChildren() as $child) { $this->writeInternal($child); } } }
/** * Get attributes from Node * * @param ProtocolNode $node * @return string */ public function getAttributesHashFromNode($node) { $txt = ''; $attributes = $node->getAttributes(); if ($attributes) { foreach ($attributes as $key => $value) { $txt .= $key . ': ' . $value . "\n"; } } return $txt; }