Newbie: simplexml_load_string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kimberly
Forum Commoner
Posts: 31
Joined: Tue Apr 21, 2009 12:48 pm

Newbie: simplexml_load_string

Post by kimberly »

Apologies again, I am new to php... :banghead:

I finally got my XML post to work!
But is seems the response I am getting back is not pure XML, it is wrapped in HTML.
And I suspect that is why I'm having trouble parsing it?

I think the response looks like this:

Code: Select all

 
<html>
<br/>HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=7EC4F5A2125F2C100CE7D47779DF07A0; Path=/vapp
Content-Type: text/html;charset=ISO-8859-1
Transfer-Encoding: chunked
Date: Sun, 26 Apr 2009 12:25:45 GMT
1ed
<?xml version="1.0" encoding="UTF-8"?><[color=#FF0000]the XML is here...[/color]>
0
<br/>
</body>
</html>
 
I say "I think" because this is what I see when I "view source" after I print the result to the browser.

I am trying to parse it like this:

Code: Select all

 
  $resultXML = simplexml_load_string($result);
 
which gives this error:
parser error : Start tag expected, '<' not found in .....
 
I also tried this:

Code: Select all

 
  $xmlResponse = "";
  $xml_parser = xml_parser_create(); 
  xml_parse_into_struct($xml_parser, $xmlResponse, $vals, $index);
  var_dump($xmlResponse);
 
which just outputs:
string(0) ""
Any help will be MUCH appreciated!

ps.
I am trying to avoid using curl since I dont have it installed and dont know if it is installed on the live server.
Last edited by Benjamin on Sun Apr 26, 2009 11:58 am, edited 2 times in total.
Reason: Added code tags.
Post Reply