Jump to content

How to display styled xml generated by a .asp link?


fishbaitfood

Recommended Posts

Hello guys,

 

I want to make an xml feed into my webpage, but the xml is generated from an .asp file on another website, so it's not actually an xml file, but xml output.

Now, I want to retrieve this xml output on my webpage, but I'm having difficulties while doing this.

 

What I've tried so far:

 

- With PHP:

<?php
echo file_get_contents("http://link-on-other-website.asp?XML=1");
?>

 

- With javascript:

<script type="text/javascript">
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","http://link-on-other-website.asp?XML=1", false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 

document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("RECORD");
for (i=0;i<x.length;i++)
  { 
  document.write("<tr><td>");
  document.write(x[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue);
  document.write("</td><td>");
  document.write(x[i].getElementsByTagName("DATE")[0].childNodes[0].nodeValue);
  document.write("</td></tr>");
  }
document.write("</table>");
</script>

 

 

When using the PHP code, I can retrieve it obviously, but I get an <?xml ... > declaration within my body, which is not allowed.

When using the Javascript code, I can't even retrieve anything.

 

And the goal is to style this xml output to match my website. That's the whole purpose of this xml link, because I couldn't style the iframe I had earlier.

 

Can someone help me on this, on how to properly embed this asp generated xml output, within my HTML5 document?

 

ps: I've asked for the xml-feed link from that other website, so using the above PHP code is legit in my case. :)

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.