Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 4 123 ... LastLast
Results 1 to 15 of 50
  1. #1
    New Coder
    Join Date
    Apr 2013
    Posts
    36
    Thanks
    15
    Thanked 0 Times in 0 Posts

    XML Coding to MAKE XML Feed appear on Page

    Hello all,

    I have tried so many things to get this to work but to no avail, can someon eplease help me out here with a simple script for n XML steam feed.

    http://api.steampowered.com/ISteamUs...380&format=xml

    OK NOW THE ISSUE IS:

    I have a blank webpage which I have placed the above link into, I simply want the contents of the XML feed from the link to appear in my page.......

    How do I make the contents of that url appear on the same page??

    SO I NEED THE SMALL SCRIPT TO DO THIS

    Also I would like to have the background a certain colour and use a certain font like 12point arial with bold headings and lower case text.

    Can someone please provide me with the html to allow this XML feed to appear on my webpage with a different colour background, arial 12pt font in bold

    and lowercase

    Could someone pleasde please help me..........

    With regards

    Mathew

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,217
    Thanks
    23
    Thanked 605 Times in 604 Posts
    Add this to the xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="zorro.xsl"?> // THIS LINE TO GET STYLING
    <!DOCTYPE achievementpercentages>

    And here is the file add your style requirements yourself:
    zorro.xsl:
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <html>
    <body>
    <table border="1">
    <tr>
    <th>ACHIEVEMENT NAME</th>
    <th>PERCENT DONE</th>
    </tr>
    <xsl:for-each select="achievementpercentages/achievements/achievement">
    <tr bgcolor="tan">
    <td>
    <xsl:value-of select="name"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="percent"></xsl:value-of>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • Users who have thanked sunfighter for this post:

    mdexter (05-01-2013)

  • #3
    New Coder
    Join Date
    Apr 2013
    Posts
    36
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Hello there,

    Ok so I understand what you are saying, I have added this to my webpage:


    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <html>
    <body>
    <table border="1">
    <tr>
    <th>ACHIEVEMENT NAME</th>
    <th>PERCENT DONE</th>
    </tr>
    <xsl:for-each select="achievementpercentages/achievements/achievement">
    <tr bgcolor="tan">
    <td>
    <xsl:value-of select="name"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="percent"></xsl:value-of>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>



    Now where to I add the xml feed link?

    http://api.steampowered.com/ISteamUs...380&format=xml



    And where do i add the:

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="zorro.xsl"?> // THIS LINE TO GET STYLING
    <!DOCTYPE achievementpercentages>


    Sorry i am a bit confused here??

    Many many thanks for replying to me

    Await your reply

    Regards

    Mathew

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,217
    Thanks
    23
    Thanked 605 Times in 604 Posts
    Sorry i am a bit confused here??
    Me too. Post a link to you web page or put the code here. Does your server allow php?
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • Users who have thanked sunfighter for this post:

    mdexter (05-01-2013)

  • #5
    New Coder
    Join Date
    Apr 2013
    Posts
    36
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sunfighter View Post
    Me too. Post a link to you web page or put the code here. Does your server allow php?

    Very sorry, ok from the top:

    The webpage the XML feed needs to go on is this site:

    www.aoe2hdozclan.com

    At the very bottom you will see a module box named:

    STEAM AoE2 HD Global Achievements (testing)

    This site hosting does not allow php coding, so the module itself has the following coding:

    <iframe src="http://www.mdexter.com/aoe2hdozclan.com/steam.htm" width="517" height="175"></iframe>

    So my other hosting site with my other website does allow php coding, the page in question where I am putting the coding is:

    http://www.mdexter.com/aoe2hdozclan.com/steam.htm

    this steam.htm page is where I need to put your coding, but I am not sure based on what you have told me what to put there on steam.htm:


    You have given me:


    ++++++++++++++++++++++++++++++++++++++++++++++++

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <html>
    <body>
    <table border="1">
    <tr>
    <th>ACHIEVEMENT NAME</th>
    <th>PERCENT DONE</th>
    </tr>
    <xsl:for-each select="achievementpercentages/achievements/achievement">
    <tr bgcolor="tan">
    <td>
    <xsl:value-of select="name"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="percent"></xsl:value-of>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>


    +++++++++++++++++++++++++++++++++++++++++++++

    AND

    +++++++++++++++++++++++++++++++++++++++++++++

    Add this to the xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="zorro.xsl"?> // THIS LINE TO GET STYLING
    <!DOCTYPE achievementpercentages>

    +++++++++++++++++++++++++++++++++++++++++++++

    So where do I put your coding, I am very sorry I am not sure where to put what.

    I understand that it needs to go into the steam.htm page along with the URL for the XML feed:

    http://api.steampowered.com/ISteamUs...380&format=xml

    also needs to go into steam.htm to show the feed in steam.htm

    and my module page which has the code:

    <iframe src="http://www.mdexter.com/aoe2hdozclan.com/steam.htm" width="517" height="175"></iframe>

    Will then show the XML feed page in the module at:

    www.aoe2hdozclan.com

    I hope this all makes sense and I am very sorry if I did not explain myself properly, out of around 20 forum posts all over the web you have been the only person who has helped me.

    I greatly appreciate your help so very much

    With regards

    Mathew

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I'm not sure if you can do this in just HTML. Unfortunately, as a backend developer, I'm not familiar with the new standards of the HTML5, so it may actually be doable. This should be doable in JS since I believe you can apply a transformation after the fact on an XML document.
    Server side wise, this is trivial to do in a language like PHP. I wouldn't use a stylesheet myself, rather I'd use the DOMDocument object to traverse the nodes given an xpath (although there's nothing wrong with taking the XML document and force attaching the stylesheet and transforming it, and then merging it with the existing HTML structure either).
    Do you have a server side processing language available to do this in?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    mdexter (05-01-2013)

  • #7
    New Coder
    Join Date
    Apr 2013
    Posts
    36
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Hello and thank you for replying, again I did not realise that this was a difficult thing to do, but I have attached an image from my other web host which does offer the PHP where the:

    http://www.mdexter.com/aoe2hdozclan.com/steam.htm

    Page sists where the code needs to go: screenshot attached

    I hope this helps
    Attached Thumbnails Attached Thumbnails XML Coding to MAKE XML Feed appear on Page-new-picture-1-.jpg  

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Its not really a difficult thing to do so much as you (I don't think anyway) can't do it in HTML. So you simply need to have a method to process it.
    With PHP, and using sunfighter's xslt saved as steamfeed.xsl, I would simply do as so:
    PHP Code:
    <?php

    $sFeed 
    'http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002/?gameid=221380&format=xml';

    $dom = new DOMDocument('1.0''utf-8');
    $xsl = new XSLTProcessor();

    $dom->load('steamfeed.xsl');
    $xsl->importStylesheet($dom);
    $dom->load($sFeed);

    print 
    $xsl->transformToXML($dom);
    Simple as that.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    mdexter (05-01-2013)

  • #9
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,217
    Thanks
    23
    Thanked 605 Times in 604 Posts
    A slight problem here Fou-Lu, to use XSLTProcessor for PHP you must first get it, install it, and then point to it in your paths. mdexter may or may not be able to do this. On the other hand XSLTProcessor is part of javascript. But this has a problem also. Both the xml and xsl have to be on your site. At lest this is the way it has been for me. There maybe a way of doing either of the two things differently than how I do them. If so I'd like to know how.

    Here's what I do.
    In your browser put the address http://api.steampowered.com/ISteamUs...380&format=xml. The xml file will display in your browser. Use your browser "View Page Source". Copy that into a file. I named my file "zorro.xml". Have both "zorro.xml" and "zorro.xsl" in same folder as next code and run that code.
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function loadXMLDoc(dname)
    {
    if (window.ActiveXObject)
      {
      xhttp=new ActiveXObject("Msxml2.XMLHTTP.3.0");
      }
    else
      {
      xhttp=new XMLHttpRequest();
      }
    xhttp.open("GET",dname,false);
    xhttp.send("");
    return xhttp.responseXML;
    }
    
    function displayResult()
    {
    xml=loadXMLDoc("zorro.xml");
    xsl=loadXMLDoc("zorro.xsl");
    // code for IE
    if (window.ActiveXObject)
      {
      ex=xml.transformNode(xsl);
      document.getElementById("example").innerHTML=ex;
      }
    // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation && document.implementation.createDocument)
      {
      xsltProcessor=new XSLTProcessor();
      xsltProcessor.importStylesheet(xsl);
      resultDocument = xsltProcessor.transformToFragment(xml,document);
      document.getElementById("example").appendChild(resultDocument);
      }
    }
    </script>
    </head>
    <body onload="displayResult()">
    <div id="example"></div>
    </body>
    </html>
    This should style your xml file and display it. Instead of using
    Code:
    <div id="example"></div>
    put it where you want.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • Users who have thanked sunfighter for this post:

    mdexter (05-01-2013)

  • #10
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    This is true, the XSL library isn't enabled by default. DOMDocument is though, so you could stick entirely with dom traversal, or even mix in some xpath as well.
    Sticking with just the table as well:
    PHP Code:
    <?php
    $sFeed 
    'http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002/?gameid=221380&format=xml';

    $dom = new DOMDocument('1.0''utf-8');
    $dom->load($sFeed);

    $achievements $dom->getElementsByTagName('achievement');
    if (
    $achievements->length 0)
    {
    ?>
    <table border="1">
    <tr>
    <th>ACHIEVEMENT NAME</th>
    <th>PERCENT DONE</th>
    </tr>
    <?
        
    foreach ($achievements AS $achievement)
        {
            
    $name $achievement->getElementsByTagName('name')->item(0)->nodeValue;
            
    $percent $achievement->getElementsByTagName('percent')->item(0)->nodeValue;
        
            
    printf("<tr><td>%s</td><td>%s</td></tr>" PHP_EOL$name$percent);
        }
    print(
    '</table>');

    }
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • The Following 2 Users Say Thank You to Fou-Lu For This Useful Post:

    mdexter (05-01-2013), sunfighter (04-30-2013)

  • #11
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,217
    Thanks
    23
    Thanked 605 Times in 604 Posts
    That code means we can use any xsl file to present xml without doctoring the xml file. Brilliant!
    I shall use this from now on.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • Users who have thanked sunfighter for this post:

    mdexter (05-01-2013)

  • #12
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    This above won't do that in particular; that's a manual iteration of the dom itself.
    Although, if you want to inject the XSLT directly, I believe that can be done as well. Let me track that down.

    Mkay, here we go. You simply inject the processing instruction:
    PHP Code:
    <?php

    $dom 
    = new DOMDocument('1.0''utf-8');
    $dom->load($sFeed);
    $xslt $dom->createProcessingInstruction('xml-stylesheet''type="text/xsl" href="thatxslt.xsl"');
    $dom->insertBefore($xslt$dom->documentElement);
    Yeah. I knew there was a way to do this.
    I haven't tested it or anything, but that should insert the instruction prior to outputting the dom. I don't see a reason why it wouldn't work remotely as well (since it's handled on this server end and not on the origin server).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    mdexter (05-01-2013)

  • #13
    New Coder
    Join Date
    Apr 2013
    Posts
    36
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Hello and thank you very much.

    Ok so the code on the page is:



    <?php

    $dom = new DOMDocument('1.0', 'utf-8');
    $dom->load($sFeed);
    $xslt = $dom->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002/?gameid=221380&format=xml"');
    $dom->insertBefore($xslt, $dom->documentElement);



    Now does the page require any other code and what page type is it??

    .htm or .php

    if its .htm does it need the html head and body section and i stick this in the head section?

    or is it .php

    and is there any header and body code that the page requires, I am just using notepad to edit the page and I am not using a html editor

    Sorry for being a pain but I tried it and the output is as such with html page with the code above only:

    load($sFeed); $xslt = $dom->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002/?gameid=221380&format=xml"'); $dom->insertBefore($xslt, $dom->documentElement);


    And with the .php page the output using the code above only is:

    Warning: DOMDocument::load() [domdocument.load]: Empty string supplied as input in /home/mp/public_html/aoe2hdozclan.com/steam1.php on line 4

    I hope this helps, I have tried a .htm and a.php and using your code only on the page and the outputs above, again do I need any extra code as I am just using a text editor not a html editor.

    I can use a html editor if required

    Many thanks

  • #14
    New Coder
    Join Date
    Apr 2013
    Posts
    36
    Thanks
    15
    Thanked 0 Times in 0 Posts
    STOP PRESS, PLEASE IGNORE LAST POST.........

    ___________________________________

    Hello guys, you are all legends is all I can say.....

    please check the very bottom of the page at:

    http://www.aoe2hdozclan.com/

    Can I please ask you, is there any way to style the php page, I mean there are the clear type borders around the text, that is the tables, is there any way to make the forllowing:

    _________________________________________

    - to have the table table a thin black line for the table cells?
    - and changing the text to arial?
    - and a different size so I can get the table within the constraint of the module?

    __________________________________________

    I have the module set at 517px wide and 175px high.

    So this is just the style of the results, is this possible at all?

    Again you guys are awesome, this is fantastic, thank you thank you thank you.

  • #15
    New Coder
    Join Date
    Apr 2013
    Posts
    36
    Thanks
    15
    Thanked 0 Times in 0 Posts
    URGENT URGENT

    Ok I have fixed it and it looks fantastic, one very serious point is it's not updating with the new stats:

    please check my stats on the page at:

    www.aoe2hdozclan.com in the second module:

    Official STEAM AoE2 HD Global Achievements

    the first few are:

    ACHIEVEMENT NAME PERCENT DONE
    ACHIEVEMENT_PREORDER 54.476409912109375
    ACHIEVEMENT_UNITS_LOST_LOW 47.047935485839844
    ACHIEVEMENT_GAMES_PLAYED_RANDOM_LOW 44.637321472167969
    ACHIEVEMENT_BUILDINGS_LOST_LOW 43.964874267578125


    I have checked the actual link directly in the browser which is updating:

    http://api.steampowered.com/ISteamUs...380&format=xml

    Please tell me someone how this can be fixed so it updates please?

    With regards


  •  
    Page 1 of 4 123 ... LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •