Jump to content

Grabbing XML before it is turned into HTML


k.soule

Recommended Posts

I've spent the better part of the night searching all over the internet for a solution to a problem I'm having with XML. The problem is, I am trying to get just the raw XML file from a server (which is shown when you view source) before it turns it into HTML via the XSL stylesheet.

 

Does anybody have any tips or pointers on how to achieve this? file_get_contents(), fopen(), and curl are all returning the server parsed HTML file; however, Firefox and IE7 show me the XML source when I view source...very strange and frustrating.

 

Hoping you guys can help!

Link to comment
Share on other sites

Thanks, I know the difference between HTML and XML...terrible advice (and quite insulting). It is not always the same, if you view source on this particular page I'm looking at, it shows raw XML; however, if you "Save page as", it will save it as the HTML document you actually see in your browser window.

 

The actual solution to those that might wander into this topic looking for help is to mimic a browser. Grab the contents via curl but be sure to add this line in, or something similar, in:

 

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');

 

This will, in the end, return the XML and not the HTML. Nifty![/code]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.