hey,
i have the following page template for a sitemap.

```
<?php
/**
 * Template Name: Sitemap
 */
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <div>
        <h3>Pages</h3>
            <ul>
                <?php wp_list_pages('title_li=&depth=0&exclude='); ?>
            </ul>
        <h3>Posts</h3>
            <?php $first = 0;?>
            <ul>
            <?php
            $myposts = get_posts('numberposts=-1&offset=$first');
            foreach($myposts as $post) :
            ?>
            <li><a href="<?php the_permalink(); ?>#b"><?php the_title(); ?></a></li>
            <?php endforeach; ?>
            </ul>
        <h3>Categories</h3>
            <ul>
                <?php wp_list_categories('title_li=&orderby=name'); ?>
            </ul>
        <h3>Tags</h3>
            <ul>    
                <?php
                $tags = get_tags();
                foreach ($tags as $tag){
                    $tag_link = get_tag_link($tag->term_id);
                    $html .= "<li><a href='{$tag_link}#b' title='{$tag->name} Tag' class='{$tag->slug}'>";
                    $html .= "{$tag->name}</a></li>";
                }
                echo $html;
                ?>
            </ul>
    </div>

<?php endwhile; endif; ?>

```

It's my intention to not define a header with or or anything like that, because this thing is only used to get loaded via an ajax call.

However the output of this thing looks like this

```
<div> 
    <h3>Pages</h3> 
    <ul> 
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> 
        <html><body> 
            <li class="page_item page-item-87"><a href="http://domain.com/account#b" title="Account">Account</a></li> 
            <li class="page_item page-item-67"><a href="http://domain.com/forum-3#b" title="Forum">Forum</a></li> 
            <li class="page_item page-item-107"><a href="http://domain.com/map#b" title="Google Map">Google Map</a></li> 
            <li class="page_item page-item-79"><a href="http://domain.com/contact#b" title="ContaCt">Contact</a></li> 
            <li class="page_item page-item-92"><a href="http://domain.com/login#b" title="Login">Login</a></li> 
            <li class="page_item page-item-93"><a href="http://domain.com/register#b" title="Register">Register</a></li> 
        </body></html> 
    </ul> 
    <h3>Posts</h3> 
    <ul> 
        <li><a href="http://domain.com/test-post#b">Test post</a></li> 
        <li><a href="http://domain.com/lorem-ipsum-test-page#b">Lorem Ipsum Test Page</a></li> 
        <li><a href="http://domain.com/hello-world#b">Hello</a></li> 
    </ul> 
    <h3>Categories</h3> 
    <ul> 
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> 
        <html><body><li class="cat-item cat-item-1"> 
            <a href="http://domain.com/category/something#b" title="Show all posts">Something</a> 
        </li></body></html> 
    </ul> 
</div> 

```

Any idea why there is a weird doctype declaration and a `<html><body>` inserted inside of every `ul`. Except for the Posts `ul`. Just weird. Why could that happen and what causes this? I actually use a html5 doctype on my website.

Thank you for the help

edit: 

```
add_filter('wp_list_pages', 'add_hash'); /*Add #hash to wp_list_pages() function*/
add_filter('wp_list_categories', 'add_hash'); /*Add #hash to wp_list_categories() function*/
function add_hash($output) {

        $dom = new DOMDocument();
        $dom->loadHTML($output);

        $a_tags = $dom->getElementsByTagName('a');

        foreach($a_tags as $a)
        {
            $value = $a->getAttribute('href');
            $a->setAttribute('href', $value . '#b');
        }

        return $dom->saveHTML();
}

```

The new DOMDocument is adding this doctype declaration and the and