simplexml problem
| From: | Dani Castaños | Date: | Mon, 31 Dec 2007 12:11:26 +0000 |
| Subject: | simplexml problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-266424@lists.php.net to get a copy of this message | ||
Hi all!
I'm using simplexml to load an xml into an object.
The XML is this:
<?xml version="1.0"?>
<request>
<customerID>3</customerID>
<appName>agenda</appName>
<ticketType>cticket_agenda_server</ticketType>
<ticketTypeID>1</ticketTypeID>
<platformID>1</platformID>
<ticketAction>addUsersToGroup</ticketAction>
</request>
When I do this:
$file = simplexml_load_file( 'file.xml' );
$ticketType = $file->ticketType;
What i really have into $ticketType is a SimpleXMLElement... not the value "cticket_agenda_server"... What am I doing wrong?
Because if I echo this value... Yes, I obtain the "cticket_agenda_server"... But if I want to use like:
$ticket = new $ticketType( $param1, $param2);
It throws:
Uncaught exception 'Exception' with message 'SimpleXMLElement::__construct() expects parameter 1 to be string, array given' in C:\Dani\htdocs\ticket_server\ticket_execute.php:134
Stack trace:
#0 C:\Dani\htdocs\ticket_server\ticket_execute.php(134): SimpleXMLElement->__construct(Array, Object(clogger))
#1 {main}
thrown
It seems like it uses $ticketType class instead the value inside.
Than you in advance