note 46948 added to function.xml-set-character-data-handler

From: Date: Thu, 28 Oct 2004 14:21:09 +0000
Subject: note 46948 added to function.xml-set-character-data-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-79254@lists.php.net to get a copy of this message
How to overide the 1024 characters limitation of xml_set_character_data_handler. Took me some time to find out how to deal with that! When calling a basic XML parser: $parseurXML = xml_parser_create(); xml_set_element_handler($parseurXML, "opentagfunction", "closetagfunction"); xml_set_character_data_handler($parseurXML, "textfunction"); The textfunction only receive 1024 characters at once, even if the text is 4000 characters long. In facts, the parser seems to split the data in pieces of 1024 characters. The way to handle that is to concatenate them. example: If you have an XML tag called UNIPROT_ABSTRACT containing a 4000 characters protein description: function textfunction($parser, $text) { if ($last_tag_read=='UNIPROT_ABSTRACT') $uniprot.=$text; } The function is called 4 times and receives 1024+1024+1024+928 characters that will be concatenated in the $uniprot variable using the ".=" concatenation fonction. Easy to do, but not documented! ---- Manual Page -- http://www.php.net/manual/en/function.xml-set-character-data-handler.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46948 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46948&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46948&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46948&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46948&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46948&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46948&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46948&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#79254) next »