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

On Thu, Feb 05, 2004 at 09:40:02AM +0900, Francis Hwang wrote:
> Say I have a string that represents an XML element that I want to
> embed into a REXML::Element, how would I do this?
>=20
> For example, if I have:
>=20
> xhtml_elt =3D REXML::Element.new( 'xhtml' )
> xhtml_string =3D "<p>foo <strong>bar</strong></p>"
>=20
> Is there a way I could get to:
>=20
> puts xhtml_elt.to_s
> =3D> <xhtml><p>foo <strong>bar</strong></p></xhtml>

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 parsed and
the correct REXML elements can be created. Sorry I couldn't help more.

--
Zachary P. Landau <kapheine / hypa.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--

On Thu, Feb 05, 2004 at 09:40:02AM +0900, Francis Hwang wrote:
> Say I have a string that represents an XML element that I want to
> embed into a REXML::Element, how would I do this?
>=20
> For example, if I have:
>=20
> xhtml_elt =3D REXML::Element.new( 'xhtml' )
> xhtml_string =3D "<p>foo <strong>bar</strong></p>"
>=20
> Is there a way I could get to:
>=20
> puts xhtml_elt.to_s
> =3D> <xhtml><p>foo <strong>bar</strong></p></xhtml>

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 parsed and
the correct REXML elements can be created. Sorry I couldn't help more.

--
Zachary P. Landau <kapheine / hypa.net>
GPG: gpg --recv-key 0x24E5AD99 | http://kapheine.hypa.net/kapheine.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

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