função xml da erro quando inserida em classe
E ai pessoal, gostaria de uma ajuda, pois está acontecendo o seguinte:
Estou criando um sistema de narração em tempo real com php e XML e estou encontrando problemas com uma função, segue o código:
class XMLManipulation {
var $XMLParser;
var $XMLFile;
var $XMLData;
function getTagStart($parser, $elements, $attrs) {
}
function getTagEnd($parser, $elements) {
}
function getCharacters($parser, $data) {
}
function XMLAutoRun() {
$this->XMLParser = xml_parser_create();
xml_set_element_handler($this->XMLParser, "getTagStart", "getTagEnd");
xml_set_character_data_handler($this->XMLParser, "getCharacters");
$this->XMLFile = fopen("0001.xml", "r");
while($this->XMLData = fread($this->XMLFile, 4096)) {
xml_parse($this->XMLParser, $this->XMLData);
}
xml_parser_free($this->XMLParser);
}
}
$XMLManipulationExit = new XMLManipulation();
echo $XMLManipulationExit->XMLAutoRun();e também o XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<sessao>
<nota>
<vereador>Amarelinho</vereador>
<texto>Lendo arquivos XML Locais. Para ler um arquivo XML local podemos utilizar a seguinte</texto>
</nota>
<nota>
<vereador>Alberto dos Santos</vereador>
<texto>Lendo um arquivo XML com PHP5. 6/Novembro/2007 por Squit. Bom, mais uma vez venho</texto>
</nota>
</sessao>
rodando o código da maneira em que está sou informado dos seguintes erros:
>
Warning: xml_parse(): Unable to call handler getTagStart() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagStart() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagStart() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagEnd() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagStart() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagEnd() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagEnd() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagStart() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagStart() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagEnd() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagStart() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagEnd() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagEnd() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getCharacters() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Warning: xml_parse(): Unable to call handler getTagEnd() in E:\webmaster\sistemas\temporeal\classXML.php on line 23
Mexendo um pouco com o código percebi que isso acontecendo por causa da classe, ou seja, quando insiro as funções dentro de uma classe acontece isso, agora se eu retiro a classe o código funciona perfeitamente, exemplo:
function getTagEnd($parser, $elements) {
}
function getCharacters($parser, $data) {
}
function XMLAutoRun() {
$XMLParser = xml_parser_create();
xml_set_element_handler($XMLParser, "getTagStart", "getTagEnd");
xml_set_character_data_handler($XMLParser, "getCharacters");
$XMLFile = fopen("0001.xml", "r");
while($XMLData = fread($XMLFile, 4096)) {
xml_parse($XMLParser, $XMLData);
}
xml_parser_free($XMLParser);
}
XMLAutoRun()
Alguém sabe como resolver isso, ou pelo menos por que isso acontece?Discussão (4)
Carregando comentários...