simplexml problem



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
.



Relevant Pages

  • Re: [PHP] simplexml problem
    ... I'm using simplexml to load an xml into an object. ... What i really have into $ticketType is a SimpleXMLElement... ...
    (php.general)
  • Re: reading a XML file on every page execution - convert to PHP?
    ... into a simpleXML node every time index.php loads. ... Including a php file requires the file be read then parsed. ... modification date- and use the .xml only if it was newer. ... cannot load, ...
    (comp.lang.php)
  • Re: How to open and read "feed:" in PHP?
    ... Question: Is a URL that starts with feed: output XML? ... Question: How do I open a feed: URL in PHP and parse it? ... I looked at the example for simpleXML on the php.net web site. ... That's because SimpleXML alows you to navigate the xml tree as you wish, foroward and backwards how many times you like. ...
    (comp.lang.php)
  • Re: Interaction between SimpleXML & DOM
    ... The above is not well-formed XML. ... Give up using SimpleXML and use DOM for everything... ... $contentDOM = new DOMDocument; ...
    (comp.lang.php)
  • Re: How to open and read "feed:" in PHP?
    ... Question: Is a URL that starts with feed: output XML? ... Question: How do I open a feed: URL in PHP and parse it? ... Now you have a SimpleXML object named $rss which you can use to iterate. ... SimpleXML alows you to navigate the xml tree as you wish, ...
    (comp.lang.php)