/    Sign up×
Community /Pin to ProfileBookmark

PHP Generated XML Gets Unexpected BR Tag

I am learning the art of using PHP to dynamically generate XML to send back to an AJAX request and I am running into an error parsing the XML due to a mysterious BR tag at the end of the XML.

Following is the stripped down (security and initialization removed) PHP code that creates the XML:
<?php
session_start();
session_id($session_id);

header(“Content-type: text/xml”);
echo ‘<?xml version=”1.0″ encoding=”UTF-8″?>’;

echo ‘<data>’;
echo ‘<comment>’.htmlentities($comment).”</comment>”;
echo ‘<commentorName>’.htmlentities($user->display_name).'</commentorName>’;
echo ‘<commentorURL>’.$user->profile_url().'</commentorURL>’;
echo ‘<commentorImage>’.$image_path.'</commentorImage>’;
echo ‘<approved>’.$approved.'</approved>’;
echo ‘<commentID>’.$new_id.'</commentID>’;
echo ‘</data>’;
?>

Is there some trick that I need to do to not include a <br /> after the closing </data> tag?

Thanks in advance for any advice!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 30.2011 — I do not see why you would get a <br /> tag there. You [i]might[/i] get a newline character if you have one after the closing ?> tag, though -- which can be avoided completely by simply leaving the closing tag out, which is not strictly needed if there is nothing to output at the end of the file after it.
×

Success!

Help @spence_74 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...