By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,915 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,915 IT Pros & Developers. It's quick & easy.

&lt &gt Problem...Ignoring specific characters like > in the XML

P: 1
I am a beginner level in xml..my output page does not convert &gt &lt it shows something like this
" <b>Location.</b><br /> <UL><LI>Park Central New York " can anyone help?
here is my code
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2.  
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4.  
  5. <xsl:template match="/">
  6.  
  7.     <html>
  8.     <head>
  9.         <style>
  10.  
  11.             body
  12.                 {
  13.                 font-family: Arial, Helvetica, sans-serif;
  14.                 font-size: 12px;
  15.                 font-style: normal;
  16.                 font-weight: normal;
  17.                 text-decoration: none;            
  18.                 }
  19.  
  20.  
  21.         </style>
  22.         <script language="javascript" type="text/javascript">
  23.  
  24.         /*            
  25.          This is the function which toggles the display of required blocks 
  26.         */
  27.  
  28.         function showHide(hotelId)
  29.         {
  30.             items=document.getElementsByName("hotelDtl");
  31.             // alert(items.length) 
  32.             for(var i = 0 ; i &lt; items.length ; i++)
  33.             {    
  34.                 items[i].style.display ="none";
  35.             }                
  36.             document.getElementById("td_"+hotelId).style.display ="";
  37.  
  38.         }
  39.  
  40.         /*            
  41.          This is the function which hides all the main blocks containing hotel information on page load
  42.         */
  43.  
  44.         function hideAll()
  45.         {
  46.             items=document.getElementsByName("hotelDtl");
  47.  
  48.              for(var i = 0 ; i &lt; items.length ; i++){
  49.                 items[i].style.display ="none";
  50.              }    
  51.         }
  52.  
  53.         </script>
  54.     </head>
  55.       <body onload="hideAll();"> 
  56.  
  57.  
  58.  
  59. <table width="70%" border="0" align="center" cellpadding="3" cellspacing="1">
  60.   <tr>
  61.     <td align="center"><b>Assignment for XSLT with ASP for rendering the XML file </b></td>
  62.   </tr>
  63.   <tr>
  64.     <td></td>
  65.   </tr>
  66.   <tr>
  67.     <td>
  68.  
  69.             <table width="80%" border="0" align="center" cellpadding="3" cellspacing="1">
  70.               <tr>
  71.                 <td width="20%">Choose Hotel : </td>
  72.                 <td>
  73.                        <!-- Populate the hotel names in a select box 
  74.                        OnChange event of this, there is a call given to a Javascript function
  75.                        This function handles, which block to show and which ones to hide
  76.                        This is achived using the HTML element attributes like name and Id
  77.                        The inbuilt javascript function getElementById is used to select the element which needs to be displayed
  78.                        The inbuilt javascript function getElementsByName is used to select the elements which needs to be hidden
  79.                        -->
  80.                        <select id="hotelName" name="hotelName" onchange="return showHide(this.value);">
  81.                                 <option value="">--Select Hotel--</option>
  82.  
  83.                                 <xsl:for-each select="HotelAvailabilityListResults/Hotel">
  84.                                     <option value="{hotelId}">
  85.                                         <xsl:attribute name="id">
  86.                                                 <xsl:value-of select='hotelId'/>                                    
  87.  
  88.                                         </xsl:attribute>
  89.                                              <xsl:value-of select="name"/>     
  90.  
  91.                                     </option>
  92.                                 </xsl:for-each>
  93.                         </select>
  94.                 </td>
  95.               </tr>
  96.             </table>    
  97.     </td>
  98.   </tr>
  99.   <tr>
  100.     <td height="10"></td>
  101.   </tr>
  102.   <tr>
  103.     <td>
  104.             <table width="80%" border="0" align="center" cellpadding="3" cellspacing="1">
  105.                 <tr>
  106.                   <td>The information of the hotel chosen is shownhere : </td>
  107.                 </tr>
  108.             </table>
  109.       </td>
  110.   </tr>
  111.   <tr>
  112.     <td height="10"></td>
  113.   </tr>
  114.   <tr>
  115.     <td>
  116.                     <table cellpadding="3" cellspacing="1" border="0" width="100%">
  117.                               <xsl:for-each select="HotelAvailabilityListResults/Hotel">
  118.                                 <tr name="hotelDtl" style="display:none">
  119.                                     <xsl:attribute name="id">
  120.                                     <xsl:text>td_</xsl:text>
  121.                                             <xsl:value-of select='hotelId'/>
  122.                                     </xsl:attribute>                        
  123.                                           <td>                                            
  124.  
  125.                                                     <table width="80%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
  126.                                                                   <tr>
  127.                                                                     <td width="40%" align="left" valign="top" bgcolor="#FFFFFF">Hotel Name </td>
  128.                                                                     <td align="left" valign="top" bgcolor="#FFFFFF"><xsl:value-of select='name'/></td>
  129.                                                                   </tr>
  130.                                                                   <tr>
  131.                                                                     <td align="left" valign="top" bgcolor="#FFFFFF">Address</td>
  132.                                                                     <td align="left" valign="top" bgcolor="#FFFFFF">
  133.                                                                         <xsl:value-of select="address1"/> 
  134.                                                                         <br />
  135.                                                                         <xsl:value-of select="address2"/>
  136.                                                                         <br />
  137.                                                                         <xsl:value-of select="address3"/>
  138.                                                                         <br />                                                                        
  139.                                                                         <xsl:value-of select="city"/> - <xsl:value-of select="10019"/>
  140.                                                                         <br />
  141.                                                                         <xsl:value-of select="stateProvince"/>
  142.                                                                         <br />
  143.                                                                         <xsl:value-of select="country"/>
  144.                                                                         <br />
  145.                                                                     </td>
  146.                                                                   </tr>
  147.                                                                   <tr>
  148.                                                                     <td align="left" valign="top" bgcolor="#FFFFFF">Description</td>
  149.                                                                     <td align="left" valign="top" bgcolor="#FFFFFF">
  150.                                                                         <xsl:value-of select="shortDescription" disable-output-escaping="no"/>
  151.                                                                     </td>
  152.                                                                   </tr>
  153.                                                                   <tr>
  154.                                                                     <td align="left" valign="top" bgcolor="#FFFFFF">Rate Information </td>
  155.                                                                     <td align="left" valign="top" bgcolor="#FFFFFF">
  156.                                                                             <table border="0" align="left" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
  157.                                                                               <tr>
  158.                                                                                 <td bgcolor="#FFFFFF">Low</td>
  159.                                                                                 <td bgcolor="#FFFFFF">$ <xsl:value-of select="lowRate"/> </td>
  160.                                                                               </tr>
  161.  
  162.                                                                               <tr>
  163.                                                                                 <td bgcolor="#FFFFFF">High</td>
  164.                                                                                 <td bgcolor="#FFFFFF">$ <xsl:value-of select="highRate"/></td>
  165.                                                                               </tr>
  166.                                                                             </table>
  167.                                                                     </td>
  168.                                                                   </tr>                                                                 
  169.                                                     </table>
  170.  
  171.  
  172.                                           </td>                                 
  173.                                 </tr>                    
  174.                               </xsl:for-each>
  175.                     </table>
  176.  
  177.  
  178.  
  179.  
  180.  
  181.     </td>
  182.   </tr>    
  183.  
  184.   <tr>
  185.     <td align="center"> </td>
  186.   </tr>  
  187. </table>    
  188.   </body>
  189.   </html>
  190. </xsl:template>
  191. </xsl:stylesheet>
  192.  
  193.  
Jul 31 '10 #1
Share this Question
Share on Google+
1 Reply


jkmyoung
Expert 100+
P: 2,057
Without the source, I'm not sure what you're specifically looking at, but trying using the disable-output-escaping attribute with element <xsl:value-of>.
Aug 4 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.