Jump to content

[SOLVED] Keep XML tags


socialmatrix

Recommended Posts

Hello, please consider following code:

 

$retval = '<value>';

$retval .= $_GET['num1'] + $_GET['num2'];

$retval .= '</value>';

echo "$retval";

 

num1 = 1 and num2 = 2.

 

on the browser, $retval echoes 3 (gets rid of XML tags). I want to modify this code to echo "<value>3</value>". what do I need to do?

 

Thank You, Thekdi

Link to comment
https://forums.phpfreaks.com/topic/119001-solved-keep-xml-tags/
Share on other sites

Thank You Scott, genericnumber1 and PFMaBiSmAd,

 

@Scott: yeah but I was hoping , browse to treat content as XML

 

@genericnumber1: that works :). However, display is still HTML. I am hoping to make browser look like what we get via RSS feeds. e.g. http://rss.cnn.com/rss/cnn_topstories.rss . OR even better if you use del.icio.us, they have a service https://api.del.icio.us/v1/posts/get? this returns XML data. This is what I want to do.

 

@PFMaBiSmAd: I thought your solution would solve above problem. However, it doesn't. Returned content is still HTML.

 

Any mor esuggestions?

 

Thanks a lot again,

Thekdi

Link to comment
https://forums.phpfreaks.com/topic/119001-solved-keep-xml-tags/#findComment-612801
Share on other sites

Thanks a lot again for consistent help.

 

Something very strange happened,

 

I have

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

at the top. But it doesn't get echoed at all.

 

Previously, I had

print '<?xml version="1.0"?>';

This never used print either!

 

Link to my service is: http://azvaishnav.info/app/index.php?method=addIt&num1=1&num2=2

Here I am calling addIt function that adds num1 and num2.

 

Do you think problem might be because I use godaddy? may be I should set up Apache Tomcat?

 

Thank You, Thekdi

Link to comment
https://forums.phpfreaks.com/topic/119001-solved-keep-xml-tags/#findComment-612807
Share on other sites

No, that echo is coming through okay, but it's a tag and won't be displayed.

 

Also, tomcat is for jsp/servlets, so no... that wouldn't help.

 

this is being echo'd:

</object></layer></span></div></table></body></html><!-- adsok -->
<script language='javascript' src='https://a12.alphagodaddy.com/hosting_ads/gd01.js'></script>

You need to stop that from being sent.

 

Are you sure you put

header('Content-Type: text/xml');

at the top of your script? my browser is still reporting it as text/html

Link to comment
https://forums.phpfreaks.com/topic/119001-solved-keep-xml-tags/#findComment-612811
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.