SimpleXML and the Single String (SOLVED)
| From: | Jay Blanchard | Date: | Tue, 21 Feb 2012 03:13:14 +0000 |
| Subject: | SimpleXML and the Single String (SOLVED) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-316752@lists.php.net to get a copy of this message | ||
Howdy,
My PHP chops are a little rough around the edges so I know that I am missing something. I am working
with SimpleXML to retrieve values from an XML file like this -
$xmlCompany = $xml->SignonRq->SignonTransport->CustId->SPName;
If I echo $xmlCompany I get the proper information.
If I use $xmlCompany as an array value though, I get this object -
$arrayLead[0]->Company = $xmlCompany; // what I did
[Company] => SimpleXMLElement Object // what I got
(
[0] => Dadgummit
)
I tried casting AND THEN AS I TYPED THIS I figured it out...
$xmlCompany = array((string) $xml->SignonRq->SignonTransport->CustId->SPName); //
becomes an array
$arrayLead[0]->Company = $xmlCompany[0]; // gets the right bit of the array
and the result is
[Company] => Dadgummit
Thanks for bearing with me!