0

Well, I'm still a noob when it comes to PHP (or anything), so I'll just give an example. If you go here: http://www.gmodules.com/ig/ifr?synd=googlemodules&w=500&h=350&mid=0&url=http://hosting.gmodules.com/ig/gadgets/file/102166312438248764726/calendar-personalized.xml you'll see the XML gadget displaying nicely in the browser window. Of course, if you load only the gadget in the browser (http://hosting.gmodules.com/ig/gadgets/file/102166312438248764726/calendar-personalized.xml) the page will display only as text.
What I want is the PHP code that does this trick. In this example is http://www.gmodules.com/ig/ifr and I suspect that it might be PHP, but I don't mind a javascript code that can 'read' and display xml gadget.
Thanks!

2
Contributors
11
Replies
12
Views
5 Years
Discussion Span
Last Post by pritaeas
0

It is just an XML CDATA block. Load this file into SimpleXML/DOMDocument, and you can do with it what you want.

0

Well, at least you didn't say something stupid like "Google is your friend".
Anyway, here's a possible hybrid sollution i found (php and jquery):

<?PHP
$xml = $_GET['xml'];
echo "<script src='http://code.jquery.com/jquery.min.js' type='text/javascript'></script>
        <script type='text/javascript'>
        $(document).ready(function(){
    function loadfail(){
        alert('Error: Failed to read the file!');
    }
    function parse(document){
        $(document).find('Module').each(function(){
           $('.combo1').append( 
            '' + $(this).find('Content').text() +
            ''
           );
        });
    }
    $.ajax({
        url: '$xml',
        dataType: 'xml',
        success: parse,
        error: loadfail
    });
});
</script><span class='combo1'></span>This text doesn't appear either.";
?>This text doesn't appear on page.

The problem is that anything else other then the module's content is hidden or doesn't load.
Any ideas, please?

0

Where's the rest of the HTML file? No html, head, body tag... Trying to append to a class named 'combo1' in an invalid HTML file will probably fail.

Edited by pritaeas

0

<span class='combo1'></span>

It works, just like I said before. The page loads only the combo1 span, bot nothing else. Everything I write before or after the combo1 doesn't show when the page load.
Anyway, I think now is a javascript problem.; probably someone should move the topic to another forum.

0

M8, I might be wrong, but it doesn't need to start with <html> and end with </html> to act like a HTML. Anyway, what is your solution? Do you have any suggestions?! And BTW, it is a PHP file, not a HTML; or, it's a PHP file that renders a HTML code.
Thx!

Edited by wattaman

0

That is true for plain HTML, but most browsers won't run Js correctly if it is invalid (because the DOM parser will fail).

0
<!DOCTYPE html>
<html>
<head>
  <script src='http://code.jquery.com/jquery.min.js' type='text/javascript'></script>
  <script type='text/javascript'>
    $(document).ready(function(){
      $.ajax({
        url: '<?php echo $xml; ?>',
        dataType: 'xml',
        success: function(document){
          $(document).find('Module').each(function(){
            $('.combo1').append($(this).find('Content').text());
          });
        },
        error: function(){
          alert('Error: Failed to read the file!');
        }
      });
    });
</script>
</head>
<body>
<span class='combo1'></span>
</body>
</html>

If you still have problems, please show any javascript errors you get, and the xml url you are trying to load.

Edited by pritaeas

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.