RE: [PHP-DB] XML coming out from MySQL

From: Date: Fri, 09 Nov 2001 22:21:44 +0000
Subject: RE: [PHP-DB] XML coming out from MySQL
Groups: php.db 
Request: Send a blank email to php-db+get-14210@lists.php.net to get a copy of this message
I've never parsed XML with PHP, but it might help if you can show the document that's breaking the parser, and also let us know if other documents are working fine... -Lorenzo -----Original Message----- From: Tomas Garcia Ferrari Sent: Fri 11/9/2001 5:14 PM To: php-db@lists.php.net Cc: Subject: [PHP-DB] XML coming out from MySQL Hello, I'm trying to parse an XML file stored on MySQL. I'm using this code: > <?php > global $CFG, $ME; > > $qid = db_query(" > SELECT texto > FROM articulos > WHERE id = $id > "); > > $r = db_fetch_object($qid); > $file = $r->texto; > > > $map_array = array( > "ARTICULO" => "", > "VOLANTA" => "h2", > "TITULO" => "h1", > "SUBTITULO" => "h3", > "BAJADA" => "h2", > "PARRAFO" => "p", > "AUTOR" => "h3", > "URL" => "h3", > "COPY" => "h3" > ); > > function startElement($parser, $name, $attrs) { > global $map_array; > if ($htmltag = $map_array[$name]) { > print "<$htmltag>"; > } > } > > function endElement($parser, $name) { > global $map_array; > if ($htmltag = $map_array[$name]) { > print "</$htmltag>"; > } > } > > function characterData($parser, $data) { > print $data; > } > > $xml_parser = xml_parser_create(); > // use case-folding so we are sure to find the tag in $map_array > xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); > xml_set_element_handler($xml_parser, "startElement", "endElement"); > xml_set_character_data_handler($xml_parser, "characterData"); > > while ($data = $file) { > if (!xml_parse($xml_parser, $data, 0)) { > die(sprintf("XML error: %s at line %d", > xml_error_string(xml_get_error_code($xml_parser)), > xml_get_current_line_number($xml_parser))); > } > } > xml_parser_free($xml_parser); > ?> and having this at the end of the outuput: > XML error: junk after document element at line 25 What does it mean? How can I solve it / trace it? Regards, Tomás +-- --+ Tomás García Ferrari Bigital http://bigital.com/ +-- --+ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#14210) next »