Python BeautifulSoup double question mark in xml definition
Question: I thought it must be a bug so i issued a bug report
[here](https://bugs.launchpad.net/beautifulsoup/+bug/984258). On the other
hand i might be missing something so i need another look on the code.

The problem is, when i initialize BeautifulSoup with contents of an .xhtml
file, xml definition gets two question marks at the end of it.

Can you reproduce the problem? Is there a way to avoid it? Am i missing a
function, a method, an argument or something?

**Edit0:** It's BeautifulSoup 4 on python 2.x.

**Edit1:** Why downvote?

* * *

The problem:

    
    
    <?xml version="1.0" encoding="UTF-8"??>
    

Terminal Output:

    
    
    >>> from bs4 import BeautifulSoup as bs
    >>> with open('example.xhtml', 'r') as f:
    ...     txt = f.read()
    ...     soup = bs(txt)
    ... 
    >>> print txt
    <?xml version="1.0" encoding="UTF-8"?>
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta charset="utf-8"/>
        </head>
        <body>
        </body>
    </html>
    
    >>> print soup
    <?xml version="1.0" encoding="UTF-8"??>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta charset="utf-8"/>
    </head>
    <body>
    </body>
    </html>
    


Answer: Consider using an XML parser:

    
    
    soup = bs(txt, 'xml')
    

