0

I'm getting a http post xml-result to my android client but there is a problem with the result. On the PHp server i echo the result and fetch the result in the android client with http response and HttpEntity.

However, in the result is just not the xml, but also html tags. When I print the result it looks like this:

<html> <body> </body> </html> xml comes here....

How do I get rid of the html from the xml result?

EDIT: I didn't need to set the response. I was using another php helper class and in that class I had html code at the top and the bottm.

1
  • Can you show us your PHP code? Do you use any templating engine? Commented Jun 27, 2011 at 16:01

2 Answers 2

1

did you tried setting response ContentType to text/xml at the php server side ??

Sign up to request clarification or add additional context in comments.

2 Comments

Altough it didn't solve my problem directly, when I did this I saw that the problem was that I was calling another PHP class where I had put html tags at the top and the bottom. Removing those sorted it out. Do I still need to set the response content type to text/html even if it works without now?
as far as I know that would be good practise if you just want to send xml .. then declare its context type as text/xml. for instancse if you want to send a pdf document you may set content type to application/pdf.. basically setting content type is closely bind to browser so that after getting the particular content type browser can actually invoke the helper application to handle the content else browser will try to display it. But in this case you are just reading the content from input stream so right now requirement for content type is not there.
1

Start trying to diagnose the problem.

Build a PHP script to carry out the post and dump the response - does it have the same tags? If so then its a problem in your PHP code. If not, it's a problem at the android end.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.