Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Transform xml pasted into textarea

11:29 pm on Nov 29, 2006 (gmt 0)

New User

10+ Year Member

joined:Aug 8, 2005
votes: 0

I have a textarea element that I want to allow users to paste the contents of an xml file into. Once pasted into the texarea I would like to transform the xml and display the html output on a new page.

Is this easily done? And if so, can anyone give a few pointers?


1:54 am on Nov 30, 2006 (gmt 0)


WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
votes: 84

XSLT is where you want to look for an answer.
(Extensible Stylesheet Language Transformations)
if you google or search WebmasterWorld you will find some answers...
11:00 am on Nov 30, 2006 (gmt 0)

New User

10+ Year Member

joined:Aug 8, 2005
votes: 0

Yeah, I know how to transform xml with xslt.

What the problem is, is that there is no xml file as such. There is only xml markup (without an xsl stylesheet link) pasted into a textarea. I would like to transform this with an xsl stylesheet that resides on the server.

How do I transform xml markup in a textarea?

I guess I'm asking how to "get at" the data within the textarea.

12:01 pm on Nov 30, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
votes: 0

to get text

text = document.getElementById( "myTextArea" ).value;

to parse it

var doc = new DOMParser().parseFromString( text, "text/xml" );
var documentElement = doc.documentElement;