I'm currently using the Botman framework to make my bot read a XML file.
Currently, my bot is able to grab data from an XML file and output it.
I'm having issue saving the XML file back into a global variable (so I can reuse later on in the code). Here is the current error message I get when trying to do this:
"message": "Serialization of 'SimpleXMLElement' is not allowed",
"exception": "Exception",
"file": "C:\\Users\\Jack\\finalyearproject\\gfyp\\gfyp\\vendor\\opis\\closure\\src\\SerializableClosure.php
I'm having issues here:
public function nodeTest($xmlFile, $answer)
{
$this->XMLFile = $xmlFile;
...
}
Here is the class code before the function:
class StartConversation extends Conversation
{
public $XMLFile;
...
public function askForDatabase()
{
$question = Question::create('Test test test?')
->fallback('Unable to create a new database')
->callbackId('create_database')
->addButtons([
Button::create('Suicide')->value('suic'),
Button::create('Self-harm')->value('sh'),
]);
$this->ask($question, function (Answer $answer) {
$xmlResult = $this->testXMLGrabFunction($answer);
if ($answer->getValue() == 'suic') {
$this->nodeTest($xmlResult, $answer);
}
if ($answer->getValue() == 'sh') {
$this->nodeTest($xmlResult, $answer);
}
});
}
}
Here is the class where I get the XML file originally:
class testClass
{
function getXMLCategory($categoryName)
{
$xml = simplexml_load_file('ST-working-age-23-3-20.xml');
if($categoryName == 'suic')
{
$xml = $xml->node[0];
return $xml;
} elseif($categoryName == 'sh') {
$xml = $xml->node[1];
return $xml;
} else {
return null;
}
}
}
Any suggestions would be great - thanks