如何使用XSLT将html的div标签转换为xml

时间:2016-10-22 15:12:16

标签: html xml xslt

我有以下HTML代码,实习生有超链接

    <div class="metro hotel_metro margbot3">  
                <a href='/directory/tour-operator/a1-bhutan-travel-services'>
                    <h5>
                <img src='http://tcb.img.ebizity.bt/images/thumb/tcb-tour_092716_IMG_7812.JPG' />
                         A1 Bhutan Travel Services 
                    </h5>
                </a>

并且href具有以下html代码

                

                    <h1 class="margbot3">
                         A1 Bhutan Travel Services 
                    </h1>
                    <table cellpadding="4" cellspacing="0" class="table_listing margright1 margbot5 w_48">
                        <tr>
                            <td width="100px" align="center">
                                <img src='http://tcb.img.ebizity.bt/images/medium/tcb-tour_092716_IMG_7812.JPG' />
                            </td>
                        </tr>
                    </table>
                    <table cellpadding="4" cellspacing="0" class="table_listing margright1 margbot5 w_48">
                        <tr>
                            <td>
                                <b>Office Hours </b>
                            </td>
                            <td>
                                9:00 AM to 5:00 PM 
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>Year Established</b>
                            </td>
                            <td>
                                2016
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>License Holder</b>
                            </td>
                            <td>
                                Pema Yangden 
                            </td>
                        </tr>
                        <tr>
                            <td width="100px">
                                <b>Address </b>
                            </td>
                            <td>
                                Chubachu, Thim Throm, Thimphu 
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>Telp </b>
                            </td>
                            <td>
                                00975- 17672013 
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>Fax </b>
                            </td>
                            <td>
                                NA
                            </td>
                        </tr>
                        <tr id="_cph_content__rpt_info__tr_email_0">
                            <td>
                                <b>Email </b>
                            </td>
                            <td>
                                <a href='mailto:pema@travelbhutan.com '>pema@travelbhutan.com </a>
                                <ul class="list_submenu" style="display: none;">
                                    <li style="list-style: none !important;"><a href="#top" id="pop">Contact
                                         A1 Bhutan Travel Services 
                                        &raquo;</a> </li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>Website </b>
                            </td>
                            <td>
                                <a href='http://www.travelbhutan.com' target='_blank'>www.travelbhutan.com</a>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <b>Specialize In</b>
                            </td>
                            <td>

    <ul>

            <li>
                Adventure
            </li>

            <li>
                Art
            </li>

            <li>
                Bird Watching
            </li>

            <li>
                Cultural
            </li>

            <li>
                Customized
            </li>

            <li>
                Cycling
            </li>

            <li>
                Festivals
            </li>

            <li>
                High-End
            </li>

            <li>
                Honeymoon
            </li>

            <li>
                Photography
            </li>

            <li>
                Pilgrimage
            </li>

            <li>
                Spiritual/Wellness
            </li>

            <li>
                Trekking
            </li>

            <li>
                White Water Rafting
            </li>

    </ul>


                            </td>
                        </tr>
                    </table>
                    <div class="clear">
                    </div>
                    <p>
Arranging Bhutan tour for regional and Foreign tourist.&nbsp;&nbsp;</p>


        </div>
    </div>
</div>

我想使用XSLT将其转换为以下XML格式

<document>
<name>A1 Bhutan Travel Services </name>
<Office Hours>9.00Am</Office Hours>
<Year Established>2015 </Year Established>

我是XSLT的新手,所以任何人都可以帮我处理将上述HTML转换为XML所需的示例XSLT。     

0 个答案:

没有答案