Never Hide Gaming Posted December 9, 2014 Share Posted December 9, 2014 Hello and thank you to anyone and everyone that responds. I am very new to XML and have done some of the tutorials, but I am having trouble getting the information to pull. The XML file is automatically updated by a website and I would like to pull information off of it to put on my own website. First off, do I need to re-load the XML file on my site first? Someone said that I was going to have to do this but I am not sure how. I feel as though this could be the error that I am facing. This is my XML file <team cacheDate="Mon 8 Dec 2014, 10:22 PM CST"> <name> <![CDATA[ Never Hide ]]> </name> <url> http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide </url> <foundedDate timestamp="1396323803">Mon 31 Mar 2014, 10:43 PM CDT</foundedDate> <reputation>Array</reputation> <arena>Call of Duty: Ghosts</arena> <platform>Xbox One</platform> <currentStats> <season> <name>Summer 2014</name> <url> http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/ladder/team/ </url> </season> <place>0</place> <previousPlace>3717</previousPlace> <matchesPlayed>14</matchesPlayed> <wins>2</wins> <losses>12</losses> <winPercentage>0.143</winPercentage> <gamesFor>8</gamesFor> <gamesAgainst>22</gamesAgainst> <shutouts>2</shutouts> <streak>-5</streak> <xp>0</xp> <level>1</level> <levelUp>1000</levelUp> </currentStats> <alltimeStats> <matchesPlayed>18</matchesPlayed> <wins>2</wins> <losses>16</losses> <winPercentage>0.111</winPercentage> <gamesFor>8</gamesFor> <gamesAgainst>31</gamesAgainst> <shutouts>2</shutouts> <streak>-5</streak> <xp>0</xp> </alltimeStats> <roster>...</roster> <recentMatches> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=45791823 ]]> </url> <date timestamp="1409732100">Wed 3 Sep 2014, 3:15 AM CDT</date> <result>L</result> <xp/> <opponent> <name> <![CDATA[ Trip cappeddd ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/trip-cappeddd ]]> </url> </opponent> </match> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=45791683 ]]> </url> <date timestamp="1409728500">Wed 3 Sep 2014, 2:15 AM CDT</date> <result>L</result> <xp/> <opponent> <name> <![CDATA[ Composure ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/----composure--- ]]> </url> </opponent> </match> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=45791490 ]]> </url> <date timestamp="1409724900">Wed 3 Sep 2014, 1:15 AM CDT</date> <result>L</result> <xp/> <opponent> <name> <![CDATA[ DingleBerry Pickers ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/dingleberry-pickers ]]> </url> </opponent> </match> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=45791385 ]]> </url> <date timestamp="1409724000">Wed 3 Sep 2014, 1:00 AM CDT</date> <result>L</result> <xp/> <opponent> <name> <![CDATA[ Bad News Bears ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/bad-news-bearsj ]]> </url> </opponent> </match> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=45431135 ]]> </url> <date timestamp="1407733200">Mon 11 Aug 2014, 12:00 AM CDT</date> <result>L</result> <xp/> <opponent> <name> <![CDATA[ The Savages and Nick ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/the-savages-and-nick ]]> </url> </opponent> </match> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=45226146 ]]> </url> <date timestamp="1406777400">Wed 30 Jul 2014, 10:30 PM CDT</date> <result>W</result> <xp/> <opponent> <name> <![CDATA[ osama bin laden squad ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/osama-bin-laden-squad ]]> </url> </opponent> </match> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=45039470 ]]> </url> <date timestamp="1405926000">Mon 21 Jul 2014, 2:00 AM CDT</date> <result>W</result> <xp/> <opponent> <name> <![CDATA[ Smoke Break ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/smoke-break ]]> </url> </opponent> </match> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=44738512 ]]> </url> <date timestamp="1404633600">Sun 6 Jul 2014, 3:00 AM CDT</date> <result>L</result> <xp/> <opponent> <name> <![CDATA[ Martins ego ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/martins-ego ]]> </url> </opponent> </match> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=44737626 ]]> </url> <date timestamp="1404628200">Sun 6 Jul 2014, 1:30 AM CDT</date> <result>L</result> <xp/> <opponent> <name> <![CDATA[ Insidious Cult ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/insidious-cult ]]> </url> </opponent> </match> <match> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/match?id=44695507 ]]> </url> <date timestamp="1404437400">Thu 3 Jul 2014, 8:30 PM CDT</date> <result>L</result> <xp/> <opponent> <name> <![CDATA[ HeaT $2.5k ]]> </name> <url> <![CDATA[ http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/heat-25k ]]> </url> </opponent> </match> </recentMatches> </team> http://gamebattles.majorleaguegaming.com/xboxone/call-of-duty-advanced-warfare/team/never-hide-gaming/stats.xml This is the code that I am trying to use. If I can get one thing to actually pull, then I can figure the rest out. I have been using the Tryit Editor so far to test everything before populating my site. <!DOCTYPE html><html><head><style>table, th, td { border: 1px solid black; border-collapse:collapse;}th, td { padding: 5px;}</style></head><body><script>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","gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/stats.xml",false);xmlhttp.send();xmlDoc=xmlhttp.responseXML; document.write("<table><tr><th>Team</th><th>Result</th></tr>");var x=xmlDoc.getElementsByTagName("recentMatches");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("result")[0].childNodes[0].nodeValue); document.write("</td></tr>"); }document.write("</table>");</script></body></html> Sorry that this is so long and drawn out, but thank you very much in advance. Link to comment Share on other sites More sharing options...
Ingolme Posted December 9, 2014 Share Posted December 9, 2014 You're missing the http:// in the URL on this line of code: xmlhttp.open("GET","gamebattles.majorleaguegaming.com/xboxone/call-of-duty-ghosts/team/never-hide/stats.xml",false); That is a necessary but not sufficient condition for this to work. The other necessary condition is that their server sends a response with a header indicating that cross-domain AJAX requests are allowed. If they are not, then you can't use AJAX to load this data. Learn more about cross-domain requests here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now