From:             sachinpkaushik at gmail dot com
Operating system: Fedora Linux
PHP version:      5.4.10
Package:          DOM XML related
Bug Type:         Bug
Bug description:Some of the urls are not added in 
$url->addchild("loc",$mainurl);

Description:
------------
I am trying to generate xml file for sitemap for google tracking of my site
url.

I have a php file with the code mentioned(Please refer the code sent) which
I am 
running on the command line with no arguments.

The code retrieves value in an array $venueArrayfrom the value recieved
from the 
function $venue->getAll()

There is a foreach loop which retrieves the value from the array
'$venueArray'.

In the foreach loop I have added a code to fetch url from array
'$venueArray' 
element 'id':- 

 $mainurl =$venue->getUrl(array("venueId"=>$venueD['id']));

and puts it in the xml tags with the help of the code

$url->addchild("loc",$mainurl);

and then the contents are appended in the file.

It seems that some of the urls are not added (url for example: 
http://mysite.com/dresden/769112-venue-theater-wechselbad-großer-saal) in
the 
following code intended to add urls:-

$url->addchild("loc",$mainurl);

Please provide me with the solution to my problem as soon as possible and
also 
please let me know the changes which I should do in order to get urls in my
xml 
file.

Some of the urls are not added in $url->addchild("loc",$mainurl);


Test script:
---------------
<?php
/** some of the urls are not added in $url->addchild("loc",$mainurl); **/

$xmltext = "<?xml version=\"1.0\" encoding=\"UTF-8\"
standalone=\"no\"?>\n<urlset
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";></urlset>";

$xmlobj = simplexml_load_string($xmltext);      

/** Code to retrieve venue array **/      
$venue = new record();     
                   
$venueArray=$venue->getAll();

/** End of the Code to retrieve venue array **/

foreach($venueArray as $venueD){
                           
                          /** Code to retrieve Url from venue array **/ 
                          $mainurl 
=$venue->getUrl(array("venueId"=>$venueD['id']));                    
                       
                           /**
                           
                           Example of the url generated
                                    
                                
http://mysite.com/dresden/769112-venue-theater-wechselbad-großer-saal
                        
                           **/
                                         
                    $url= $xmlobj->addChild("url");                     
                    $url->addchild("loc",$mainurl);
                    $url->addChild("lastmod",date('Y-m-d'));
                    $url->addChild("changefreq","daily");
                    $url->addChild("priority","0.9");           

              $fp=fopen('test.xml',"a");
                      fwrite($fp,$xmlobj->asXML());
                      fclose($fp); 
}

?>

Expected result:
----------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9";>
  <url>
   
<loc>http://mysite.com/dresden/769112-venue-theater-wechselbad-großer-
saal</loc>
    <lastmod>2012-12-21</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.9</priority>
  </url>
</urlset>

Actual result:
--------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9";>
  <url>
  <loc/>
    <lastmod>2012-12-21</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.9</priority>
  </url>
</urlset>

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63853&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63853&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63853&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63853&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63853&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63853&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63853&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63853&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63853&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63853&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63853&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63853&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63853&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63853&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63853&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63853&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63853&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63853&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63853&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63853&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63853&r=mysqlcfg

Reply via email to