php - Writing to a file adds weird content at the end of the line -
i working on programme parses text files uploaded user , saves parsed xml file on server. however, when write xml file text

at end of each line. text not in original text file. didn't notice until opened new xml file verify righting of content. has ran before , if can tell me if it's due way i'm creating , writing file?
fileupload.php - these 3 lines occur when user uploads file.
$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 origin of file $pconjs = $this->getpconjlist(); //convert xml string $xml = $book->asxml(); //combine list of pconj's , xml string $xml = "$pconjs\n$xml"; homecoming $xml; }
input text file
1:1 x seemed me also, x having had perfect understanding of things first write orderly account, [most] first-class theophilius , 1:4 may know certainty of things in instructed 1:5 x there in days of herod, king of judea , priest named zacharias x wife[was] of daughters of aaron , name [was] elizabeth. 1:8 was, while serving priest 1:9 before god in order of division, 1:10 , whole multitude of people praying outside @ hr of incense hence done.

ascii character \r\n
doesn't seem come out correctly parseunformattedtext()
.
try $xml = nl2br($parser->parseunformattedtext($filecontents));
php xml
No comments:
Post a Comment