Я работаю над программой, которая анализирует текстовые файлы, загруженные пользователем, а затем сохраняет анализируемый XML-файл на сервере. Однако, когда я пишу файл XML, я получаю текстЗапись в файл добавляет странный контент в конце строки

в конце каждой строки. Этот текст не находится в моем исходном текстовом файле. Я даже не заметил этого, пока не открыл новый XML-файл, чтобы убедиться, что он исправляет все содержимое. Кто-нибудь сталкивался с этим раньше, и если да, то можете ли вы сказать мне, связано ли это с тем, как я создаю и записываю свой файл?
fileUpload.php - Эти 3 строки возникают, когда пользователь загружает файл.
$fileName = basename($_FILES['fileaddress']['name']);
$fileContents = file_get_contents($_FILES['fileaddress']['tmp_name']);
$xml = $parser->parseUnformattedText($fileContents);
$parsedFileName = pathinfo($fileName, PATHINFO_FILENAME) . ".xml";
file_put_contents($parsedFileName, $xml);
parser.php
function parseUnformattedText($inputText, $bookName = "")
{
//create book, clause, text nodes
$book = new SimpleXmlElement("<book></book>");
$book->addAttribute("bookName", $bookName);
$conj = $book->addChild("conj", "X");
$clause = $book->addChild("clause");
$trimmedText = $this->trimNewLines($inputText);
$trimmedText = $this->trimSpaces($inputText);
$text = $clause->addChild("text", $trimmedText);
$this->addChapterVerse($text, "", "");
//make list of pconj's for beginning of file
$pconjs = $this->getPconjList();
//convert the xml to string
$xml = $book->asXml();
//combine the list of pconj's and xml string
$xml = "$pconjs\n$xml";
return $xml;
}
Входной текстовый файл
1:1 X
it seemed good to me also,
X
having had perfect understanding of all things from the very first
to write you an orderly account, [most] excellent Theophilius
and
1:4
that
you may know the certainty of those things in which you were instructed
1:5 X
There was in the days of Herod, the king of Judea and a certain priest named Zacharias
X
his wife[was] of the daughters of Aaron
and
her name [was] Elizabeth.
1:8 So
it was,
that
while he was serving as priest 1:9 before God in the order of his division,
1:10 and
the whole multitude of the people was praying outside at the hour of incense
but
therefore
it was done.
Возможно, этот? '$ xml =" $ pconjs \ n $ xml "; ' – Ghost
Я так не думаю, потому что он появляется перед новой строкой. – tylerbhughes
хорошо его трудно узнать с этой стороны, мы не знаем, что входной вход в любом случае – Ghost