Link to home
Start Free TrialLog in
Avatar of Danbob
Danbob

asked on

simplexml_load_string returning false when loading xml?

Hello everyone -

I am encountering a problem when trying to load a simple xml stream into a simplexml_load_string object.  I am retrieving the xml from a webservice, and var_dumps at the appropriate places verify that it is being recieved properly.  However, when I instantiate the simplexml_load_string object and load the xml into it, it returns false.

I've attached the XML I receive from the var_dump just before I instantiate below.

I'm not sure why this is not loading, any help would be invaluable.
$xml_content = $web_service_result; <--- this is the result called from another function, simple xml

var_dump($xml_content); <-- this returns the xml I added below, all looks to be fine...

$xml = simplexml_load_string($xml_content); <-- I attempt to load the xml into the object here...

var_dump($xml); <-- this outputs bool(false)

Here is the XML I receive:

<?xml version="1.0" encoding="utf-8"?>
<Eligibility>
  <CustID>9</CustID>
  <FirstName>EMPLOYEE</FirstName>
  <LastName>Smith</LastName>
  <Box>BOX</Box>
  <Member>MIC</Member>
  <Email>E-fulfillment2@blah.com</Email>
  <Phone>1236273300</Phone>
  <Address1>321 MAIN ST</Address1>
  <Address2>
  </Address2>
  <City>NEW YORK</City>
  <State>NY</State>
  <PostalCode>10019</PostalCode>
  <CountryCode>US</CountryCode>
</Eligibility>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Danbob
Danbob

ASKER

Thank you both, bportlock's solution was correct... And Ray, I greatly appreciate your assistance as well.  Thanks for taking teh time to help.  Works great now!