I am trying to parse XML into an array using the orchestra, which is the XML Parser package for Laravel. When I try to run the code, I get the error "Unable to parse XML from string." Below is the test.xml file that I am trying to parse in an array.
<?xml version="1.0" encoding="utf-8"?>
<api>
<user followers="5">
<id>1</id>
<email>crynobone@gmail.com</email>
</user>
</api>
and in my controller I am trying to parse an XML file
public function index()
{
$xml = XmlParser::load('test.xml');
$user = $xml->parse([
'id' => ['uses' => 'user.id'],
'email' => ['uses' => 'user.email'],
'followers' => ['uses' => 'user::followers'],
]);
print_r($user);
}
Does anyone have an idea why I don't understand the xml array?
source
share