logo       

Re: How can I insert "raw" (X|XHT|HT)ML into my DOM?: msg#00023

java.enhydra.xmlc

Subject: Re: How can I insert "raw" (X|XHT|HT)ML into my DOM?

Hello David:

While the following "cheat" is officially frowned upon, I'm convinced it's
necessary in a very few hard cases (where you are dynamically inserting data
that already contains markup, and the pain of creating appropriate dom
objects is 20 times greater than the guilt you may feel about taking the
easier way out).

page.setTextContents(""); // remove any placeholder text

CDATASection cds = page.createCDATASection ([some data containing markup you
want used as markup]);

page.getElementContents().appendChild(cds);

....
out.print(page.toDocument(request, response)).....


There may be other variations. CDATASection is the key. Its exempt from
having its markup characters escaped.

-Joe



----- Original Message -----
From: "David Corbin" <dcorbin@xxxxxxxxxxxxxx>
To: <xmlc@xxxxxxxxxxx>
Sent: Wednesday, January 15, 2003 5:39 PM
Subject: Xmlc: How can I insert "raw" (X|XHT|HT)ML into my DOM?


> I have an application where I have access to some Markup Language in
> string form. I would like to (effectively) insert that into my DOM as a
> single unprocessable chunk so that when I render my DOM, it get's
> rendered as HTML rather then as a TextNode. The only solution I can see
> is to parse that HTML and insert it as DOM objects, and I really rather
> not have to do that.
>
> Thanks for any tips.
>
> David
>
> _______________________________________________
> XMLC mailing list
> XMLC@xxxxxxxxxxx
> http://www.enhydra.org/mailman/listinfo.cgi/xmlc
>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise