XML coming out from MySQL

From: Date: Fri, 09 Nov 2001 22:14:21 +0000
Subject: XML coming out from MySQL
Groups: php.db 
Request: Send a blank email to php-db+get-14207@lists.php.net to get a copy of this message
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/ +-- --+

« previous php.db (#14207) next »