Lennie
Lennie

Reputation: 2069

PHP Variable loses XML

I have the following XML in a variable:

$xml = 'XML=<CktRequest><Agent Name="Computicket" Group="mobile"></Agent><Operation Type="New Session" NumNewReleases="3" NumPromotions="6"/></CktRequest>';
var_dump("xml:".$xml);

The var_dump only show:

'XML='

So it loses everything after that... Why?

Upvotes: 0

Views: 72

Answers (3)

thebod
thebod

Reputation: 452

Better let the browser display the content as text and put on the beginning of your code (after "< ?php"):

header('Content-type: text/plain');

This also helps with line-breaks ;-)

Upvotes: 0

Ben Everard
Ben Everard

Reputation: 13804

The browser is interpreting the tags as... well tags. View the source to see the contents of $xml or escape it first:

var_dump("xml:" . htmlentities($xml));

Upvotes: 2

Repox
Repox

Reputation: 15476

You are propably having the full content shown, but viewing it through the browser it will try parsing it as HTML.

Try viewing the source code of you page. I'll bet you it's there.

Upvotes: 0

Related Questions