note 57415 added to ref.xml

From: Date: Mon, 03 Oct 2005 15:54:12 +0000
Subject: note 57415 added to ref.xml
Groups: php.notes 
Request: Send a blank email to php-notes+get-96302@lists.php.net to get a copy of this message
I liked too the xmlparser class by monte, but trying to parse a tag with some '\n' chars cause some problems. Parsing this file: <?xml version="1.0" encoding="iso-8859-1"?> <example>line1 line2 line3</example> it returns that: Array ( [0] => Array ( [name] => EXAMPLE [content] => line3 ) ) making some debugs print I saw that the function splits "line1 line2 line3" in 3 strings, and for 3 times she will write the content in the same array cell, so at the end only "line3" will remain. I think to have solved this problem (if I can call it so) modifying this function: <?PHP function dataHandler($parser, $data){ if(!empty($data)) { $_output_idx = count($this->output) - 1; echo "datahandler: id=".$_output_idx." data: ".$data."<br><br>"; $this->output[$_output_idx]['content'] .= $data; // just changed '= $data' with '.=$data' } } ?> now the output is: Array ( [0] => Array ( [name] => EXAMPLE [content] => line1 line2 line3 ) ) maybe you can help me understanding why the function breaks the tag content in apart when finding a '\n' char. Leo Borsari USI Lugano Swiss ---- Manual Page -- http://www.php.net/manual/en/ref.xml.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57415 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57415&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57415&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57415&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57415&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57415&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57415&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57415&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57415&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#96302) next »