# Adding any \<text/\> to a rexml doc (bump)

**URL:** <https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326>\
**Category:** ruby-talk\
**Created:** [15 December 2005 18:57 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326 "2005-12-15T18:57:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [15 December 2005 18:57 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326/1 "2005-12-15T18:57:34Z")

</div>

is there know way to do this

&nbsp;&nbsp;&nbsp;require "rexml/document"

&nbsp;&nbsp;&nbsp;include REXML

&nbsp;&nbsp;&nbsp;Text::new " i \< know & what i'm doing "

it seems not...

-a

> **···**
>
> # --
> 
> > ara [dot] t [dot] howard [at] noaa [dot] gov  
> > all happiness comes from the desire for others to be happy. all misery  
> > comes from the desire for oneself to be happy.  
> > -- bodhicaryavatara
> 
> ===============================================================================

---

<div class="post-metadata">

**Author:** ![Patrick\_Gundlach2](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Patrick\_Gundlach2](https://rubytalk.org/u/Patrick_Gundlach2)\
**Post date:** [15 December 2005 23:12 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326/2 "2005-12-15T23:12:40Z")

</div>

Hi,

> is there know way to do this
> 
> &nbsp;&nbsp;&nbsp;require "rexml/document"
> 
> &nbsp;&nbsp;&nbsp;include REXML
> 
> &nbsp;&nbsp;&nbsp;Text::new " i \< know & what i'm doing "
> 
> it seems not...

I am not sure, what you want to do, but perhaps

Text.unnormalize(" i \< know & what i'm doing ") is the answer?

REXML won't let this into the element hierarchy, afaik.

Patrick

---

<div class="post-metadata">

**Author:** ![Anonymous\_Coward](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@Anonymous\_Coward](https://rubytalk.org/u/Anonymous_Coward)\
**Post date:** [16 December 2005 03:24 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326/3 "2005-12-16T03:24:09Z")

</div>

> is there know way to do this
> 
> &nbsp;&nbsp;&nbsp;require "rexml/document"
> 
> &nbsp;&nbsp;&nbsp;include REXML
> 
> &nbsp;&nbsp;&nbsp;Text::new " i \< know & what i'm doing "
> 
> it seems not...

Perhaps it is time to try Builder or htree? 🙂

> -a

E

> **···**
>
> On 2005.12.16 03:57, ara.t.howard@noaa.gov wrote:

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [16 December 2005 01:47 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326/4 "2005-12-16T01:47:07Z")

</div>

it will - you just have to trick it:

&nbsp;&nbsp;&nbsp;element.text =  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::REXML::Text::new(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string\_we\_want\_untouched,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;respect\_whitespace=true,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent=nil,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raw=true,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity\_filter=nil,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;illegal=%r/.^/m # match nothing!  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)

sean, if you're reading this a feature in the api to allow this would be great.

cheers.

-a

> **···**
>
> On Fri, 16 Dec 2005, Patrick Gundlach wrote:
> 
> > Hi,
> > 
> > > is there know way to do this
> > > 
> > > &nbsp;&nbsp;&nbsp;require "rexml/document"
> > > 
> > > &nbsp;&nbsp;&nbsp;include REXML
> > > 
> > > &nbsp;&nbsp;&nbsp;Text::new " i \< know & what i'm doing "
> > > 
> > > it seems not...
> > 
> > I am not sure, what you want to do, but perhaps
> > 
> > Text.unnormalize(" i \< know & what i'm doing ") is the answer?
> > 
> > REXML won't let this into the element hierarchy, afaik.
> 
> # --
> 
> > ara [dot] t [dot] howard [at] noaa [dot] gov  
> > all happiness comes from the desire for others to be happy. all misery  
> > comes from the desire for oneself to be happy.  
> > -- bodhicaryavatara
> 
> ===============================================================================

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [16 December 2005 05:38 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326/5 "2005-12-16T05:38:42Z")

</div>

i can't stand the builder api. htree is good - but i'm not looking for a  
template engine - does it provide hooks to generate html without using  
templates. the code i'm working on attm can do things like this:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ahoward@localhost xx-0.0.0]$ cat a.rb  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require "xx"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class Table \< ::Array  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include XX::XHTML

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def to\_xhtml  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xhtml\_\_{

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html\_\_{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;head\_\_{ title\_\_{ "table demo" } }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h1\_\_(:style =\> :sweet){ "this is a table " }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h\_\_{ "\<malformed html & open tags" }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;table\_\_(:width =\> 42, :height =\> 42){  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;each{|row| tr\_\_{ row.each{|cell| td\_\_ cell } } }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}.pretty  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts Table[%w( 0 1 2 ), %w( a b c )].to\_xhtml

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ahoward@localhost xx-0.0.0]$ ruby -I./lib a.rb  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt](http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<html lang='en' xml:lang='en' xmlns='[http://www.w3.org/1999/xhtml&#39;&gt](http://www.w3.org/1999/xhtml&#39;&gt);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<head\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<title\>table demo\</title\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</head\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<h1 style='sweet'\>this is a table \</h1\>\<malformed html & open tags\<table height='42' width='42'\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<tr\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>0\</td\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>1\</td\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>2\</td\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</tr\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<tr\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>a\</td\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>b\</td\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>c\</td\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</tr\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</table\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</html\>

coming soon to a store near you 😉

regards.

-a

> **···**
>
> On Fri, 16 Dec 2005, Eero Saynatkari wrote:
> 
> > On 2005.12.16 03:57, ara.t.howard@noaa.gov wrote:
> > 
> > > is there know way to do this
> > > 
> > > &nbsp;&nbsp;&nbsp;require "rexml/document"
> > > 
> > > &nbsp;&nbsp;&nbsp;include REXML
> > > 
> > > &nbsp;&nbsp;&nbsp;Text::new " i \< know & what i'm doing "
> > > 
> > > it seems not...
> > 
> > Perhaps it is time to try Builder or htree? 🙂
> 
> # --
> 
> > ara [dot] t [dot] howard [at] noaa [dot] gov  
> > all happiness comes from the desire for others to be happy. all misery  
> > comes from the desire for oneself to be happy.  
> > -- bodhicaryavatara
> 
> ===============================================================================

---

<div class="post-metadata">

**Author:** ![Ezra\_Zygmuntowicz3](https://avatars.discourse-cdn.com/v4/letter/e/c57346/32.png) [@Ezra\_Zygmuntowicz3](https://rubytalk.org/u/Ezra_Zygmuntowicz3)\
**Post date:** [16 December 2005 04:34 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326/6 "2005-12-16T04:34:07Z")

</div>

Ahh thats what the non matching regex was for...

Cheers-

-Ezra Zygmuntowicz  
WebMaster  
Yakima Herald-Republic Newspaper  
ezra@yakima-herald.com  
509-577-7732

> **···**
>
> On Dec 15, 2005, at 5:47 PM, ara.t.howard@noaa.gov wrote:
> 
> > On Fri, 16 Dec 2005, Patrick Gundlach wrote:
> > 
> > > Hi,
> > > 
> > > > is there know way to do this
> > > > 
> > > > &nbsp;&nbsp;&nbsp;require "rexml/document"
> > > > 
> > > > &nbsp;&nbsp;&nbsp;include REXML
> > > > 
> > > > &nbsp;&nbsp;&nbsp;Text::new " i \< know & what i'm doing "
> > > > 
> > > > it seems not...
> > > 
> > > I am not sure, what you want to do, but perhaps
> > > 
> > > Text.unnormalize(" i \< know & what i'm doing ") is the answer?
> > > 
> > > REXML won't let this into the element hierarchy, afaik.
> > 
> > it will - you just have to trick it:
> > 
> > &nbsp;&nbsp;element.text =  
> > &nbsp;&nbsp;&nbsp;&nbsp;::REXML::Text::new(  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string\_we\_want\_untouched,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;respect\_whitespace=true,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent=nil,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raw=true,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity\_filter=nil,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;illegal=%r/.^/m # match nothing!  
> > &nbsp;&nbsp;&nbsp;&nbsp;)
> > 
> > sean, if you're reading this a feature in the api to allow this would be great.
> > 
> > cheers.
> > 
> > -a

---

<div class="post-metadata">

**Author:** ![Anonymous\_Coward](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@Anonymous\_Coward](https://rubytalk.org/u/Anonymous_Coward)\
**Post date:** [16 December 2005 05:48 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326/7 "2005-12-16T05:48:20Z")

</div>

> \>\>  
> \>\>  
> \>\>  
> \>\>  
> \>\> is there know way to do this  
> \>\>  
> \>\> require "rexml/document"  
> \>\>  
> \>\> include REXML  
> \>\>  
> \>\> Text::new " i \< know & what i'm doing "  
> \>\>  
> \>\> it seems not...  
> \>  
> \> Perhaps it is time to try Builder or htree? 🙂
> 
> i can't stand the builder api. htree is good - but i'm not looking for a  
> template engine - does it provide hooks to generate html without using  
> templates. the code i'm working on attm can do things like this:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ahoward@localhost xx-0.0.0]$ cat a.rb  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require "xx"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class Table \< ::Array  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include XX::XHTML
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def to\_xhtml  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xhtml\_\_{
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;html\_\_{  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;head\_\_{ title\_\_{ "table demo" } }
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h1\_\_(:style =\> :sweet){ "this is a table " }
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h\_\_{ "\<malformed html & open tags" }
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;table\_\_(:width =\> 42, :height =\> 42){  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;each{|row| tr\_\_{ row.each{|cell| td\_\_ cell } } }  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}.pretty  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts Table[%w( 0 1 2 ), %w( a b c )].to\_xhtml
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ahoward@localhost xx-0.0.0]$ ruby -I./lib a.rb  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt](http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt);  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<html lang='en' xml:lang='en' xmlns='[http://www.w3.org/1999/xhtml&#39;&gt](http://www.w3.org/1999/xhtml&#39;&gt);  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<head\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<title\>table demo\</title\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</head\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<h1 style='sweet'\>this is a table \</h1\>\<malformed html & open tags\<table height='42' width='42'\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<tr\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>0\</td\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>1\</td\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>2\</td\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</tr\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<tr\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>a\</td\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>b\</td\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>c\</td\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</tr\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</table\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</html\>
> 
> coming soon to a store near you 😉

Very nice! (Well, sans underscores:)

Will you make libxml2[1] an alternative backend? It is quite  
a bit faster, which may or may not be important to people.

> regards.
> 
> -a

E

[1] [http://xml-tools.rubyforge.org](http://xml-tools.rubyforge.org)

> **···**
>
> On 2005.12.16 14:38, ara.t.howard@noaa.gov wrote:
> 
> > On Fri, 16 Dec 2005, Eero Saynatkari wrote:  
> > \> On 2005.12.16 03:57, ara.t.howard@noaa.gov wrote:

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [16 December 2005 05:39 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326/8 "2005-12-16T05:39:23Z")

</div>

caught in the act... mine worked.. but it wasn't nice looking 😉

-a

> **···**
>
> On Fri, 16 Dec 2005, Ezra Zygmuntowicz wrote:
> 
> > Ahh thats what the non matching regex was for...
> 
> # --
> 
> > ara [dot] t [dot] howard [at] noaa [dot] gov  
> > all happiness comes from the desire for others to be happy. all misery  
> > comes from the desire for oneself to be happy.  
> > -- bodhicaryavatara
> 
> ===============================================================================

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [16 December 2005 06:07 UTC](https://rubytalk.org/t/adding-any-text-to-a-rexml-doc-bump/23326/9 "2005-12-16T06:07:39Z")

</div>

> > coming soon to a store near you 😉
> 
> Very nice! (Well, sans underscores:)

glad you like the look of it. i struggled with the underscore thing and  
here's how i got there:

&nbsp;&nbsp;&nbsp;- wanted access to instance data. ergo mixin. ergo can't be clobbering the  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objects methods with a billion others.

&nbsp;&nbsp;&nbsp;- didn't want a 'blanket' method missing. i wanted to a way to say that  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;only 'tag' methods would be handled in method\_missing - not everything.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;otherwise

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;syntax\_error 42

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;makes

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<syntax\_error\>42\</syntax\_error\>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fine for small docs. not for big ones. mine works like

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def method\_missing m, \*a, &b  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if m.to\_s =~ %r/\_$/  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;so only some methods (those with \_\_) get routed to method\_missing

&nbsp;&nbsp;&nbsp;- needed to address methods/tag like 'p', 'a', 'i' - which can easily be  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;methods and/or local vars

&nbsp;&nbsp;&nbsp;- wanted a way to skim the code and be able to tell which methods were  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;generating tags and which were not

&nbsp;&nbsp;&nbsp;- wanted a way to bounce on the % key in vi and balance tags... well that  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;one doesn't have to do with underscores i guess...

anyhow. i hope people will row to see that being able to \_\_safely\_\_ mixin  
these kinds of html generation methods, still being able to find syntax  
errors, and being able to quickly tell markup methods from others makes it  
o.k. my boss and i struggled with it - but it was the best approach in the  
end when considering the above.

> Will you make libxml2[1] an alternative backend?

i'd be happy to look at it... send me a link if it's not on raa or  
rubyforge...

> It is quite a bit faster, which may or may not be important to people.

it is. this will be used on dynamic websites.

> [1] [http://xml-tools.rubyforge.org](http://xml-tools.rubyforge.org)

oh. didn't see that at first 😉

cheers.

-a

> **···**
>
> # On Fri, 16 Dec 2005, Eero Saynatkari wrote: --
> 
> > ara [dot] t [dot] howard [at] noaa [dot] gov  
> > all happiness comes from the desire for others to be happy. all misery  
> > comes from the desire for oneself to be happy.  
> > -- bodhicaryavatara
> 
> ===============================================================================
