Professional Web Applications Themes

Creating mixed content elements in REXML - Ruby

Say I have a string that represents an XML element that I want to embed into a REXML::Element, how would I do this? For example, if I have: xhtml_elt = REXML::Element.new( 'xhtml' ) xhtml_string = "<p>foo <strong>bar</strong></p>" Is there a way I could get to: puts xhtml_elt.to_s => <xhtml><p>foo <strong>bar</strong></p></xhtml> Francis...

  1. #1

    Default Creating mixed content elements in REXML

    Say I have a string that represents an XML element that I want to
    embed into a REXML::Element, how would I do this?

    For example, if I have:

    xhtml_elt = REXML::Element.new( 'xhtml' )
    xhtml_string = "<p>foo <strong>bar</strong></p>"

    Is there a way I could get to:

    puts xhtml_elt.to_s
    => <xhtml><p>foo <strong>bar</strong></p></xhtml>

    Francis
    Francis Guest

  2. #2

    Default Re: Creating mixed content elements in REXML

    --oyUTqETQ0mS9luUI
    Content-Type: text/plain; cht=us-ascii
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    On Thu, Feb 05, 2004 at 09:40:02AM +0900, Francis Hwang wrote: 

    I'm no expert, but after looking at the REXML source, I don't think this
    is possible without changing the REXML code itself. I tried:"

    xhtml_elt =3D REXML::Element.new('xhtml', nil, {:raw=3D>:all})
    xhtml_elt.text =3D '<p>foo <strong>bar</strong></p>"

    but the second line raises an Illegal character '<' in raw string blah
    blah blah. There don't seem to be any options to avoid this. You
    probably don't want to do this, but you could have the string pd and
    the correct REXML elements can be created. Sorry I couldn't help more.

    --
    Zachary P. Landau <net>
    GPG: gpg --recv-key 0x24E5AD99 | http://kapheine.hypa.net/kapheine.asc

    --oyUTqETQ0mS9luUI
    Content-Type: application/pgp-signature
    Content-Disposition: inline

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (GNU/Linux)

    iD8DBQFAIcq7CwWyMCTlrZkRAnsHAJ46vyb6cpCg/BijdtwWz9TB+3CULQCfX9lp
    DKUtVzwsM1wRtq81dxNgRwA=
    =8P37
    -----END PGP SIGNATURE-----

    --oyUTqETQ0mS9luUI--


    Zachary Guest

  3. #3

    Default Re: Creating mixed content elements in REXML

    net (Francis Hwang) wrote in message news:<google.com>... 

    Oh, for Pete's sake. All I had to do was use REXML::Doent#root.

    irb(main):001:0> require 'rexml/doent'
    => true
    irb(main):002:0> string = "<p>foo <strong>bar</strong></p>"
    => "<p>foo <strong>bar</strong></p>"
    irb(main):003:0> REXML::Doent.new( string ).root.to_s
    => "<p>foo <strong>bar</strong></p>"
    Francis Guest

Similar Threads

  1. creating flash content in realtime?
    By HumanZ00 in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: April 28th, 06:53 PM
  2. Mixed content in CFGRID
    By korby in forum Coldfusion Flash Integration
    Replies: 4
    Last Post: April 9th, 05:40 PM
  3. straight photography vs. creating images in Elements
    By Eric Matthes in forum Adobe Photoshop Elements
    Replies: 21
    Last Post: September 20th, 03:41 PM
  4. Replies: 2
    Last Post: July 16th, 09:49 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139