Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2010
    Posts
    58
    Thanks
    10
    Thanked 3 Times in 3 Posts

    XML noob question

    I need to use XLM to populate the content for a web page. I'm usung XSLT to do this.

    I have a paragraph and I want to wrap one word in a <span> tag for CSS.

    So let's say I have this paragraph in XML

    Code:
    <paragraph>
    Suspendisse interdum, nisi vehicula facilisis cursus, magna nulla luctus enim, porttitor accumsan felis massa at justo.
    </paragraph>
    I use a template like this to render it into HTML

    Code:
    <xsl:template match="paragraph">
        <xsl:value-of select="."/>
    </xsl:template>
    How can I add a tag to the first word in the paragraph so I can wrap it in a <span> tag in the template so it outputs the HTML like this.

    Code:
    <p>
        <span>Suspendisse</span>  interdum, nisi vehicula facilisis cursus, magna nulla luctus enim, porttitor accumsan felis massa at justo.
    </p>

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,263
    Thanks
    10
    Thanked 277 Times in 276 Posts
    Your XML would look like this:
    Code:
    <paragraph>
    <![CDATA[<span>Suspendisse</span> interdum, nisi vehicula facilisis cursus, magna nulla luctus enim, porttitor accumsan felis massa at justo.]]>
    </paragraph>


  •  

    Posting Permissions

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