PHP - 使用表单将字符串添加到XML文件

I'm trying using a form to add strings to a XML file but I'm probably missing something, can you help me finding the error? This is the index.php sample:

<form action="feedhandler.php" method="POST">
    <input name="link" type="text" placeholder="Enter URL here."/>
    <input type="submit" name="submit" value="Import">
</form>

and this is the feedhandler.php:

<?php

$url = substr($link, strpos($link,'?')+1);
$title = array();
parse_str($url, $title);

$addMe = "<item>
    <title>$title</title>
    <link>$url</link>
    <description></description>
    </item>

<!-- DYNAMIC INFO END HERE -->";

$text = file_get_contents('feed.xml');
str_replace('<!-- DYNAMIC INFO END HERE -->', $addMe, $text);

file_put_contents('feed.xml', $text);

?>

I'm trying to import a magnet link from a torrent in a XML file as a new item and scan and break the url to import the magnet title too. A magnet url has a particular syntax: magnet:?xt=urn:btih:MAGNET_ID&dn=MAGNET_TITLE&tr=MAGNET_TRACKERS where &dn= holds the magnet title. I'm just trying to import the entire link as a link for the rss new item and its title as title. Hope I'm clear enough..