SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question XML, XSL and ASP - <p> tags vanish

    I've got 3 files that build 1 webpage. The Description element in the XML file has <p> tags in it for each paragraph within the description. But when the output page renders, all the <p> tags are missing. How can I fix this?

    Thanks

    Books.asp
    ========
    Code:
    <%
    	  '------ DISPLAY THE XML DATA ------------
    	  ' Linking XML and XSL together
    	  Dim sourceFile, styleFile, source, style
    	  sourceFile = Server.MapPath("xml/books_amazon.xml")
    	  styleFile = Server.MapPath("xml/books_amazon.xsl")
    	  
    	  set source = Server.CreateObject("Microsoft.XMLDOM")
    	  source.async = false
    	  source.load(sourceFile)
    	  set style = Server.CreateObject("Microsoft.XMLDOM")
    	  style.async = false
    	  style.load(styleFile)
    	  Response.Write source.transformNode(style)
    	%>
    books_amazon.xsl
    =============
    Code:
    	  <xsl:for-each select="Books/Book">
    	  <div class="Book">
    	  	<a href="{Link}"><img src="images/books/{Image}" alt="{Title} {SubTitle}" class="cover" /></a>
    	  	<div class="BookInfo">
    	  		<h2><xsl:value-of select="Title"/></h2>
    	  		<h3><xsl:value-of select="SubTitle"/></h3>
    	  		<h4>by <xsl:value-of select="Author"/></h4>	
    			<xsl:value-of select="Description"/>
    	  		<a href="{Link}" class="order"><img src="images/buy-from-amz-tan.gif" /></a>
    			<span class="isbn">ISBN: <xsl:value-of select="ISBN"/></span>
    	  	</div>
    	  </div>
    	  <hr />
    	  </xsl:for-each>
    books_amazon.xml (sample)
    ==============

    Code:
    <Books>
    	<Book>
    		<Author>Joe Smith</Author>
    		<Title>Some Title</Title>
    		<SubTitle>For Dummies</SubTitle>
    		<Image>5550001230.jpg</Image>
    		<Description>
    		<p>blah blah paragraph 1</p>
    		<p>here is yet another paragraph.</p>
    		<p>have you read the words inthis book?.</p>
    		</Description>
    		<ISBN>5550001230</ISBN>
    		<Link>http://www.amazon.com/blah</Link>
    	</Book>
    </Books>
    You can see the output at: http://www.standwithus.com/books.asp

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Instead of
    Code:
    <xsl:value-of select="Description"/>
    Try this:
    Code:
    <xsl:for-each select="Description/p">
    <p><xsl:value-of select="." /></p>
    </xsl:for-each>

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet! It worked, thanks.

    I tried something similar at first, but I didnt have this correct: value-of select="."

    Thanks again.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •