XML into MySQL using PHP

I am just start with PHP and XML, my xml file (phuket.xml) as


<Rx>
<hotel hno="676386">
<hno>676386</hno>
<region>phuket</region>
<hoteltag>3rdstreet</hoteltag>
<prov_id>73</prov_id>
<prov_en>Phuket</prov_en>
<prov_th>&#3616;&#3641;&#3648;&#3585;&#3655;&#3605;</prov_th>
<hotelname>3 Rd Street Cafe & Guesthouse</hotelname>
<hotelname_th>&#3626;&#3634;&#3618;&#3626;&#3634;&#3617;&#3588;&#3634;&#3648;&#3615;&#3656; &#3649;&#3629;&#3609;&#3604;&#3660;&#3648;&#3585;&#3626;&#3605;&#3660;&#3648;&#3630;&#3657;&#3634;&#3626;&#3660;</hotelname_th>
<hoteladr>Kata Night Bazaar 100/3-4, Kata Road, Karon</hoteladr>
<hotelcity>Muang, Phuket 83100</hotelcity>
<location>Kata Beach</location>
<hotellink note="depreciated">
http://www.R24.org/thailandallhotel.com/phuket/3rdstreet/
</hotellink>
<hotellink2>
http://thailandallhotel.com.r24.asia/676386/3-Rd-Street-Cafe-and-Guesthouse
</hotellink2>
<minrate_th excl="17%">1020</minrate_th>
<minrate_us excl="17%">34.22</minrate_us>
<minrate cur="USD" sym="$" sgn="$" dec="2">34.22</minrate>
<breakfast>excl</breakfast>
<promote/>
<geo_lat>7.8256</geo_lat>
<geo_long>98.2969</geo_long>
<distance_mt/>
<list_ctrl>3</list_ctrl>
<rating>2.5</rating>
</hotel>
<hotel hno="676282">
<hno>676282</hno>
<region>phuket</region>
<hoteltag>woraburiphuket</hoteltag>
<prov_id>73</prov_id>
<prov_en>Phuket</prov_en>
<prov_th>&#3616;&#3641;&#3648;&#3585;&#3655;&#3605;</prov_th>
<hotelname>Woraburi Phuket Resort & Spa</hotelname>
<hotelname_th>&#3623;&#3619;&#3610;&#3640;&#3619;&#3637; &#3616;&#3641;&#3648;&#3585;&#3655;&#3605; &#3619;&#3637;&#3626;&#3629;&#3619;&#3660;&#3607; &#3649;&#3629;&#3609;&#3604;&#3660; &#3626;&#3611;&#3634;</hotelname_th>
<hoteladr>199, 201 Tambol Karon, Amphur Karon,</hoteladr>
<hotelcity>Phuket 83100</hotelcity>
<location>Karon Beach</location>
<hotellink note="depreciated">
http://www.R24.org/thailandallhotel.com/phuket/woraburiphuket/
</hotellink>
<hotellink2>
http://thailandallhotel.com.r24.asia/676282/Woraburi-Phuket-Resort-and-Spa
</hotellink2>
<minrate_th excl="17%">1540</minrate_th>
<minrate_us excl="17%">51.71</minrate_us>
<minrate cur="USD" sym="$" sgn="$" dec="2">51.71</minrate>
<breakfast>incl</breakfast>
<promote>recommend</promote>
<geo_lat>7.8440</geo_lat>
<geo_long>98.2952</geo_long>
<distance_mt/>
<list_ctrl>3</list_ctrl>
<rating>3.0</rating>
</hotel>
.
.
.
</Rx>

I try to load above xml file to mysql according to


<?php
$oDOM = new DOMDocument();
$oDOM->loadXML(file_get_contents('phuket.xml')); #See: http://msdn.microsoft.com/en-us/library/ms762271(VS.85).aspx
foreach ($oDOM->getElementsByTagName('hotel') as $oBookNode)
{
    $sSQL = sprintf(
        "INSERT INTO phuket (hno, region, hoteltag) VALUES ('%s', '%s', '%s')",
        mysql_real_escape_string($oBookNode->getElementsByTagName('hno')->item(0)->nodeValue),
        mysql_real_escape_string($oBookNode->getElementsByTagName('region')->item(0)->nodeValue),
        mysql_real_escape_string($oBookNode->getElementsByTagName('hoteltag')->item(0)->nodeValue)
    );
    $rResult = mysql_query($sSQL);
    
    if(mysql_errno() > 0)
    {
        printf(
            '<h4 style="color: red;">Query Error:</h4>
            <p>(%s) - %s</p>
            <p>Query: %s</p>
            <hr />',
            mysql_errno(),
            mysql_error(),
            $sSQL
        );
    }    
}
?>

The result come out with the following error
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Extra content at the end of the document in Entity, line: 27 in C:\Ampps\www\php\LoadXMLNode.php on line 3

how can i correct the code.
Thanks in advance for suggestion.

To answer your question, google seems to suggest that your XML file is mal-formatted.

Be sure you escape your ampersands (&) using & instead of & in your XML file. Same with quotes ’ and " should be escaped too when used in an attribute using ' and " respectively.