Current location: Hot Scripts Forums » General Web Coding » HTML/XHTML/XML » Display XML via Browser


Display XML via Browser

Reply
  #1 (permalink)  
Old 08-19-09, 05:01 AM
zyphers zyphers is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Question Display XML via Browser

Hi ,

Let me introduce a little about my project first.
I use CakePHP to create web service for my office.

So I have WSDL file for web service (PHP Soap).
And this WSDL (which is of cause XML file) display "Blank" in browser but when I clicked view source I saw my XML in there. This lead to problem that web service could not work.

Summary :
Normally XML file should display (in browser) like this.
http://xmlfiles.com/examples/simple.xml
XML show "Blank" in browser but for view source I can see it.

Technical Details :
Apache 2.2.8
PHP 5.2.6
CakePHP 1.2.4.8284 (CakePHP: the rapid development php framework. Home)

Somebody have any idea, thank you very much
Zyphers

Last edited by zyphers; 08-19-09 at 05:14 AM. Reason: Reduce misunderstanding from Nico comment
Reply With Quote
  #2 (permalink)  
Old 08-19-09, 05:07 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Not sure if I understood you right, are you generating the XML with a PHP script?

If so, you might need to send the correct Content-Type header to the browser.
PHP Code:

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

Reply With Quote
  #3 (permalink)  
Old 08-19-09, 05:20 AM
zyphers zyphers is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for comments

I understand your point so It might be me who is misunderstanding.
Here is what I tried to do.

I have "somename.wsdl" file. I think normally we can view it via directly like any other xml file.
Like we browse to http://xmlfiles.com/examples/simple.xml

So that I cannot set up header like you said because I didn't generate it from php. Hope you get what I said.

One more thing I'm sorry. English is not my 1st language so I may be confuse you somehow

But really thanks

Last edited by zyphers; 08-19-09 at 05:21 AM. Reason: wrong typo
Reply With Quote
  #4 (permalink)  
Old 08-19-09, 05:30 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Technically there should be no problem opening and viewing the file in the browser.

Do you have a link to this page? (You can PM me the link if you don't want to post it here).


And your English is good, don't worry
Reply With Quote
  #5 (permalink)  
Old 08-19-09, 05:47 AM
zyphers zyphers is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Oh I'm sorry. I tested it on my local computer so I don't have live system and later on it will be used internally.

And yes I think like you it will be ok to open file from browser. Do WSDL file have something different from XML? since I guess It has ...

Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
...at the top of the file like other XML.

Actually any other file I worked with it worked fine but I use CakePHP so this one is surely the problem but I cannot find the bug so I need to know what could be the problem that make it display as blank

Maybe cache, header or server issue I don't know. So I just collect idea that may lead to solution, thanks
Reply With Quote
  #6 (permalink)  
Old 08-20-09, 12:28 AM
zyphers zyphers is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Trophee

Yo, Nico!

You're right there is something wrong with header.
Actually it's me who made misunderstanding, my XML file was generated from PHP code.
I though I was the same as open file via browser.
So I used this code to check header.

PHP Code:

headers_list() 

And I can see that "Content-type" is not "application/xml".
So I have to fix it somehow but anyway I know that where is the problems.
Just set the header as what you said.
Thanks again
Reply With Quote
  #7 (permalink)  
Old 08-20-09, 01:35 AM
zyphers zyphers is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, now I solved it! Set the header as what it should be!
The thing is I had a problem about I cannot modify header!
because there is white space at...
Quote:
?>
the end of script! someone suggest that remove the with space or the end tag itself.

So thanks you the problem is solved.
Reply With Quote
Reply

Bookmarks

Tags
display, xml


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
display result of ip scanner in browser! morpheus123 The Lounge 3 07-24-07 02:01 PM
Browser wants to download -- not display -- HTML files from my server mangled Web Servers 5 01-20-07 01:39 PM
Display vistor IP, Browser, OS, Hostname, Country Nubier General HotScripts Site Discussion 0 09-10-05 11:19 PM


All times are GMT -5. The time now is 09:07 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.