Skip to content
This repository has been archived by the owner on Dec 24, 2019. It is now read-only.

Urlset not preset #16

Open
jarodium opened this issue Oct 16, 2016 · 9 comments
Open

Urlset not preset #16

jarodium opened this issue Oct 16, 2016 · 9 comments

Comments

@jarodium
Copy link

jarodium commented Oct 16, 2016

Hello, I am trying to validate a sitemap file this class generates and I am encountering the following errors in W3c validator:

closing urlset is missing

-invalid markup validation of https php phoenixes rhcloud com sitemapper_check php w3c markup validator

Thanks

@aduh95
Copy link

aduh95 commented Oct 20, 2016

Hello @jarodium,
Could you provide the PHP script used to generate the non-valid sitemap you're dealing with?
Thank you

@jarodium
Copy link
Author

builder

$sitemap = new Sitemap($dominio);
    $sitemap->setFilename($dominio_id);
    $sitemap->setPath(getenv('OPENSHIFT_DATA_DIR').'sitemaps/');
    foreach($paths as $c) {
        $dom = ($dominio != $c) ? str_replace("$dominio","",$c) : $c;
        $sitemap->addItem($dom, '0.5', 'weekly', 'Today');
    }
`
reader ( i don't read directly from the sitemap index, go to the sitemap directly ):
```php
function remove_utf8_bom($text)
{
    $bom = pack('H*','EFBBBF');
    $text = preg_replace("/^$bom/", '', $text);
    return $text;
}
    header("Content-type: text/xml");
    echo trim(remove_utf8_bom(file_get_contents(getenv('OPENSHIFT_DATA_DIR')."sitemaps/5628afa9-eb78-4930-a6e5-8cc76d1a2113.xml")));
    echo '</urlset>';
`

@evert
Copy link
Owner

evert commented Oct 24, 2016

I don't have a lot of time unfortunately to work on this project, so the best way to get this fixed is by submitting a pull request

@jarodium
Copy link
Author

I will try to patch it up and submit a PR.

@jarodium
Copy link
Author

Do you mind if I change the class to use SimpleXML? It's just that in the docs, i've found out that end-element immediately closes the element, but from what I can infer is that there is no reference being kept to urlset, thus, endElement will not close it. I've tried to use a solution in the man page with no luck.

Perhaps a switch to SimpleXML would be simpler as it can retain the parent element in a variable and we can close it in the endsitemap function.

@evert
Copy link
Owner

evert commented Oct 24, 2016

My intent is actually to switch to sabre/xml: http://sabre.io/xml/ If you're willing to make that change instead I'd definitely be happy about that. simplexml I consider a step backwards though.

@jarodium
Copy link
Author

I will take a look at sabre/xml. Looks good xD

@jeiman
Copy link

jeiman commented Apr 21, 2017

Hey guys, any updates on this issue? @jarodium @evert ?

@evert
Copy link
Owner

evert commented Apr 21, 2017

Nope!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants