I have XML code like this:
<hotels> <hotel contact="(855) 23 430 732"> <name>hotel A</name> <type>hotel or apartment</type> <rating>1 to 5</rating> <address> <houseNo>73 </houseNo> <street>Preah Monivong Blvd </street> <Sangkat>Mean Chey</Sangkat > <Khan>Daun Penh</Khan> <city>Bangkok</city> </address> <room> <roomType>hotel: standard/deluxe, apartment: studio/2-bedroom/3-bedroom</roomType> <price>209</price> <description>Descriptions</description> </room> <room> <roomType>hotel: standard/deluxe, apartment: studio/2-bedroom/3-bedroom</roomType> <price>210</price> <description>Descriptions</description> </room> <room> ..... </room> </hotel> <hotel contact="..."> ... ... ... ... </hotel> </hotels> Using xsl code how I can read it? This is my code:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>test xsl</h2> <table border="1"> <tr bgcolor="#9acd32"> <th style="text-align:left;">Name</th> <th style="text-align:left;">Type</th> <th style="text-align:left;">Rating</th> <th style="text-align:left;">Address</th> <th style="text-align:left;">Room</th> </tr> <xsl:for-each select="hotels/hotel"> <tr> <!--<xsl:value-of select="."/>--> <td><xsl:value-of select="name" /></td> <td><xsl:value-of select="type" /></td> <td><xsl:value-of select="rating" /></td> <td><xsl:value-of select="address" /></td> <td><xsl:value-of select="room" /></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> problemMy code is nothing errors but for <room> can load only first child. Any one has experience with xsl please help me to solve it
No comments:
Post a Comment