Stupid question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ayende Rahien

    Stupid question

    I've an XML document that has HTML data inside one of the tags (with < & >
    encoding as &lt; etc)
    I'm Transform()ing the document using output method="html", but I get the
    &lt; encoding instead of < > and friends.
    How do I make this work?
    If I just throw the HTML data (it's well formed) to the document and select
    the containing node's contents I get the text without any HTML Formatting.
    If I encode it using &lt; I get the same &lt; as I put in, instead of
    reversing it to <
    If I put it in a CData (using < & > OR &lt;) I get &lt; !
    I'm sure it's a simple question, but I've been googling for the past hour
    without success.


  • Julian F. Reschke

    #2
    Re: Stupid question

    Ayende Rahien wrote:[color=blue]
    > I've an XML document that has HTML data inside one of the tags (with < & >
    > encoding as &lt; etc)
    > I'm Transform()ing the document using output method="html", but I get the
    > &lt; encoding instead of < > and friends.
    > How do I make this work?
    > If I just throw the HTML data (it's well formed) to the document and select
    > the containing node's contents I get the text without any HTML Formatting.[/color]

    You are probably using

    <xsl:value-of select="." />

    Instead, use:

    <xsl:copy-of select="node()" />

    [color=blue]
    > If I encode it using &lt; I get the same &lt; as I put in, instead of
    > reversing it to <
    > If I put it in a CData (using < & > OR &lt;) I get &lt; !
    > I'm sure it's a simple question, but I've been googling for the past hour
    > without success.
    >
    >[/color]

    Comment

    • Ayende Rahien

      #3
      Re: Stupid question


      "Julian F. Reschke" <julian.reschke @nospam-greenbytes.de> wrote in message
      news:OcedenIwDH A.2408@tk2msftn gp13.phx.gbl...[color=blue]
      > Ayende Rahien wrote:[color=green]
      > > I've an XML document that has HTML data inside one of the tags (with < &[/color]
      >[color=green]
      > > encoding as &lt; etc)
      > > I'm Transform()ing the document using output method="html", but I get[/color][/color]
      the[color=blue][color=green]
      > > &lt; encoding instead of < > and friends.
      > > How do I make this work?
      > > If I just throw the HTML data (it's well formed) to the document and[/color][/color]
      select[color=blue][color=green]
      > > the containing node's contents I get the text without any HTML[/color][/color]
      Formatting.[color=blue]
      >
      > You are probably using
      >
      > <xsl:value-of select="." />
      >
      > Instead, use:
      >
      > <xsl:copy-of select="node()" />[/color]

      Thanks, that works.


      Comment

      • Eugene Bykov [MSFT]

        #4
        Re: Stupid question

        Hello Ayende,
        You can try to use disable-output-escaping attribute to solve the problem.
        For example: <xsl:value-of select="." disable-output-escaping = "yes/>

        --
        Thanks,
        Eugene
        -------------------------
        This posting is provided "AS IS" with no warranties, and confers no rights.
        Use of included script samples are subject to the terms specified at
        http://www.microsoft.com/info/cpyright.htm.



        "Ayende Rahien" <Ayende@no.spam > wrote in message
        news:u6pTr2HwDH A.2456@TK2MSFTN GP12.phx.gbl...[color=blue]
        > I've an XML document that has HTML data inside one of the tags (with < & >
        > encoding as &lt; etc)
        > I'm Transform()ing the document using output method="html", but I get the
        > &lt; encoding instead of < > and friends.
        > How do I make this work?
        > If I just throw the HTML data (it's well formed) to the document and[/color]
        select[color=blue]
        > the containing node's contents I get the text without any HTML Formatting.
        > If I encode it using &lt; I get the same &lt; as I put in, instead of
        > reversing it to <
        > If I put it in a CData (using < & > OR &lt;) I get &lt; !
        > I'm sure it's a simple question, but I've been googling for the past hour
        > without success.
        >
        >[/color]


        Comment

        Working...