k.soule Posted June 17, 2009 Share Posted June 17, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/162493-grabbing-xml-before-it-is-turned-into-html/ Share on other sites More sharing options...
RussellReal Posted June 17, 2009 Share Posted June 17, 2009 what you see in view source is the same that you get returned to you thru file_get_contents, xml looks like html.. Quote Link to comment https://forums.phpfreaks.com/topic/162493-grabbing-xml-before-it-is-turned-into-html/#findComment-857645 Share on other sites More sharing options...
k.soule Posted June 17, 2009 Author Share Posted June 17, 2009 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] Quote Link to comment https://forums.phpfreaks.com/topic/162493-grabbing-xml-before-it-is-turned-into-html/#findComment-857650 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.