Need to turn & --> &amp for my sitemap. HELP

Discussion in 'PHP' started by Blinksy, Apr 15, 2007.

  1. #1
    Hi,

    I currently and attempting to create a google sitemap for a phpnuke site.

    I get the following message,

    The XML page cannot be displayed 
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. 
    
    
    --------------------------------------------------------------------------------
    
    A semi colon character was expected. Error processing resource 'http://www.metalthrone.net/sitemap.xml'. Line 90, Position...
    
      <loc>http://www.metalthrone.net/modules.php?name=Content&pa=showpage&pid=1</loc> 
    -------------------...
     
    
    Code (markup):

    Now apparently i need to turn every & into an &amp;

    Does anyone know how this could be done, in order to make the bots point to the correct link, and also, so i dont have to manually change over 30000 links in a sitemap?

    Thanks in advance.
     
    Blinksy, Apr 15, 2007 IP
  2. sundaybrew

    sundaybrew Numerati

    Messages:
    7,294
    Likes Received:
    1,260
    Best Answers:
    0
    Trophy Points:
    560
    #2
    No there is an error on line 90 of the sitemap
     
    sundaybrew, Apr 15, 2007 IP
  3. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Yes may be your coding is correct there is an error in metalthrone.net use some other site providing xml and then check.
     
    Subikar, Apr 16, 2007 IP
  4. Blinksy

    Blinksy Well-Known Member

    Messages:
    415
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #4
    every & in xml apparently introduces something, which causes xml to look for the concluding ;


    I have over 30k links all with & in them. If i delete one link, line 90 turns into line 91 with the error.

    Im sorry i dont know much about this(probably confusing you all), just a little here and there and from what ive read.

    Thanks
     
    Blinksy, Apr 16, 2007 IP
  5. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    There is problem with & in

    <loc>http://www.metalthrone.net/modules.php?name=Content&pa=showpage&pid=1</loc>

    replace all & with &amp.
    May be this can correct the problem
     
    Subikar, Apr 16, 2007 IP
  6. Blinksy

    Blinksy Well-Known Member

    Messages:
    415
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #6
    Is there no quicker way?? lol


    there are over 60 thousand of those in the code? not just the one line?


    I have been using the online sitemap generators and none of them seem to have a way around this?

    Cheers.
     
    Blinksy, Apr 16, 2007 IP
  7. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Whenever you are fetch the data and creating xml just run a preg_replace function to change & to &amp that will solve the problem. :)
     
    Subikar, Apr 16, 2007 IP
  8. Blinksy

    Blinksy Well-Known Member

    Messages:
    415
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #8
    I am not sure how to do that unfortunately?

    Is this a piece of code which goes into the xml file?
     
    Blinksy, Apr 16, 2007 IP
  9. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #9
    <?php echo htmlentities('your original data'); ?>
    PHP:
    Content for xml files ( which is what sitemaps are ) always needs to be encoded in this way.
     
    krakjoe, Apr 16, 2007 IP
    sundaybrew likes this.
  10. sundaybrew

    sundaybrew Numerati

    Messages:
    7,294
    Likes Received:
    1,260
    Best Answers:
    0
    Trophy Points:
    560
    #10

    Joe, welcome back buddy,

    When I saw this thread I knew , you would be the one to answer!

    to the op:

    This guy knows his shit op, Listen to him :)
     
    sundaybrew, Apr 16, 2007 IP