public function setTarget($key, $value)
    {
        $unit = $this->searchForId($key, true);

        $target = $this->getXPathFirstItem('xliff:target', $unit);

        // If already present check.
        if ($target === null) {
            $target = $unit->appendChild($this->doc->createElementNS(self::NS, 'target'));
        } elseif ($target->firstChild) {
            // If already present, we have to remove the textnode if one exists as otherwise the value will get
            // appended.
            $target->removeChild($target->firstChild);
        }

        $target->appendChild($this->doc->createTextNode($value));
    }