Search code examples
xmlperlspecial-characterssaxparser

how o skip characters in the sax parser perl


I have a problem in reading special characters in perl. I have the following xml file and Iam using a sax parser which loop on each hotel and take the values but when it read HotelInfo it we skip the text because we have a special charterers in the 1000 m�

<?xml version="1.0" encoding="UTF-8"?>
<XMLResponse>
    <ResponseType>HotelListResponse</ResponseType>
    <RequestInfo>
        <AffiliateCode>NI9373</AffiliateCode>
        <AffRequestId>2</AffRequestId>
        <AffRequestTime>2015-10-29T15:52:05</AffRequestTime>
    </RequestInfo>
    <TotalNumber>264234</TotalNumber>
    <Hotels>
        <Hotel>
            <HotelCode>AD0BFU</HotelCode>
            <OldHotelId>0</OldHotelId>
            <HotelLocation/>
            <HotelInfo>Renovated in 2001, Hotel Bringue features a 1000 m� garden and comprises 5 floors with 105 double rooms, 2 suites and 7 single rooms. Hotel Bringue is situated in the picturesque village El Serrat, boasting the most amazing mountain views in the region and just a short drive to the main ski resort of Vallnord.After an exhausting day, you can go for a relaxing swim in the pool, re-energise your body in the jacuzzi or pamper yourself in the sauna. The rooms are beautifully appointed and come with an array of modern amenities for a pleasant stay.</HotelInfo>
            <HotelTheme>Ski Hotels</HotelTheme>
        </Hotel>
    </Hotels>
</XMLResponse>  

How I can skip like there characters in the sax parser.


Solution

  • If you're trying to fix the file, I'm not sure why an XML parser is even needed here.

    perl -i~ -pe's/\xC3\xAF\xC2\xBF\xC2\xBD//g' file.xml