Is there simpler way to export html within xml

Hi,

we’re exporting a lot of html code within xml, our current method works
but it’s very messy - far from perfect, is there a better way to do
this.

an example of our controller code is

html = html + “<img src=”/icon/icon_email.gif"
onclick="javascript:document.getElementById(‘detail’).style.display=‘none’;
document.getElementById(‘mailform’).style.display=‘inline’;
“/>\n”

as you can see we’re using the < etc to generate the html required,
so the end result is something like

<marker html="

so within that xml tag you can see a html= option, and within that
option lives all our html.

can anyone suggest a cleaner better way to do this? it would really be
appreciated.

thanks

Is it too naive to suggest using the view (or a pseudo view) to generate
the
html using erb? After all that is what erb is for.
Colin

2009/5/7 Todd F. [email protected]

how would that work?

Todd F. wrote:

how would that work?

we need the html in xml (html wrapped inside the xml) for another
application read and then render that html.

I am not sure exactly what you would do, I am also not sure exactly what
you
are doing with the xml. It just seems that an erb view is the ideal
tool
for generating html to be sent to the client. Is there a lot of xml or
is
it just a wrapper round the html? If only a wrapper then you could
generate
that ‘by hand’ so to speak in the erb file also, or in the layout file.

Can anyone else help? I do not really know what I am talking about here.

Colin

2009/5/7 Todd F. [email protected]

sorry more info on what it’s used for would help, the xml is being read
by google maps api so we can load html code inside the popup bubble.

so yeah we dont really control the consuming end :frowning:

thanks Marnen and everyone, do you know of any examples or something i
can have a look at to get my head around it?

Todd F. wrote:

sorry more info on what it’s used for would help, the xml is being read
by google maps api so we can load html code inside the popup bubble.

so yeah we dont really control the consuming end :frowning:

It seems to me, then, that you have two good options. Either use ERb
and/or Builder to put the HTML in the XML DOM, or (if the HTML has to be
a string) use a CDATA section. Don’t make your life harder with all
those &entities;.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Todd F. wrote:

thanks Marnen and everyone, do you know of any examples or something i
can have a look at to get my head around it?

What’s to get your head around? Just pretend your XML file is an HTML
page, and proceed accordingly with your favorite template language (ERb,
Builder, Haml, Markaby, whatever). There’s no new concept involved.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

My bad MLK.

On Thu, May 7, 2009 at 9:28 AM, Todd F.
[email protected] wrote:

we need the html in xml (html wrapped inside the xml) for another
application read and then render that html.

Does the html need to be an attribute? Or can it just be within an
xml envelope? IOW, do you control the consuming end of this?


Hassan S. ------------------------ [email protected]

what are you talking about hugh?! :expressionless:

thanks Marnen, we’ll try to render xml using an erb this week and let
everyone know if we can do it and how :stuck_out_tongue:

Way to be appreciative of someone trying to help you. Good luck with
that.

On May 7, 9:50 pm, Marnen Laibow-Koser <rails-mailing-l…@andreas-

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs