Help with XML Sitemap

Discussion in 'HTML & Website Design' started by paul_whiting09, May 25, 2014.

  1. #1
    Hello i'm in need of some help with a sitemap i have created in xml. It is in a php document and I am using,

    $xml=simplexml_load_file("sitemap.xml");
    print_r($xml);

    To load the file in the php document. This is what I get. Can anyone tell me what i'm doing wrong, why it's not layed out properly?

    http://imgur.com/YAYhnc9

    
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
    <title>DVD World | Sitemap</title>
        
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        
    <link rel="stylesheet" type="text/css" href="style.css" />
        
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
                          $('.active-links').click(function () {
                                                   if ($('#signin-dropdown').is(":visible")) {
                                                   $('#signin-dropdown').hide()
                                                   $('#session').removeClass('active');
                                                   } else {
                                                   $('#signin-dropdown').show()
                                                   $('#session').addClass('active');
                                                   }
                                                   return false;
                                                   });
                          $('#signin-dropdown').click(function(e) {
                                                      e.stopPropagation();
                                                      });
                          $(document).click(function() {
                                            $('#signin-dropdown').hide();
                                            $('#session').removeClass('active');
                                            });
                          });
    </script>
                          
    </head>
                          
    <body class="home page page-id-3 page-template-default" id="themebody">
    
    <?php
    include 'header.php';
    
    echo '<br /><br />';
    echo '<div id="menu_wrapper">';
    echo '<div class="menu"><ul id="menu-top" class="sf-menu"><li id="menu-item-46" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-3 current_page_item menu-item-46"><a href="index.php">Home</a></li>';
    echo '<li id="menu-item-45" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-45"><a href="products.php">Products</a></li>';
    echo '<li id="menu-item-61" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-61"><a href="product.php">The Wolverine</a></li>';
    echo '<li id="menu-item-44" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-44"><a href="privacy.php">Privacy Policy</a></li>';
    echo '</ul></div>';
    
    echo '<br /><br /><div align="center"><a href="product.php"><img src="images/wolverine_banner.png" title="The Wolverine" /></a></div>';
    echo '</div>';
    
    echo '</div>';
    echo '</div>';
    
    echo '</div>';
    echo '</div>';
    
    echo '<div class="footer_wrapper">';
    
    $xml=simplexml_load_file("sitemap.xml");
    print_r($xml);
    
    echo '</div>';
    include 'footer.php';
    ?>
    
    </body>
    </html>
    
    Code (markup):
     
    paul_whiting09, May 25, 2014 IP
  2. Helge Sverre

    Helge Sverre Prominent Member Affiliate Manager

    Messages:
    840
    Likes Received:
    99
    Best Answers:
    2
    Trophy Points:
    305
    Digital Goods:
    2
    #2
    What do you mean not laid out correctly, it's working perfectly, what you're doing is to print_r the XML file object thingy, that will give you a string that looks like that.
    Print_r should not be used like that on a live site.

    You need to specify which data you want to grab from the php object that gets returned when you parse the xml file.

    I wrote a blog post about this, you can read it here: http://helgesverre.com/blog/how-to-parse-xml-in-php/
     
    Helge Sverre, May 25, 2014 IP