views:

34

answers:

2

Hey guys,

So I'm trying to write a javascript plugin that involves the editing of XML files in a user friendly fashion. The goal is to receive an XML string representing an object, dynamically generate an HTML form to edit the XML values, then save the changes back into the XML string.

Granted this function is generic and useful enough, I figured there's likely a solution that does exactly this out there. Does anyone know of some sort of JavaScript library or project that can accomplish this? The closest thing I can find to the functionality I wanted was this.

Some notable constraints for the solution:

  • Must be solely Javascript, ideally cross-browser compatible.
  • Must operate completely on the client-side, from input XML string, to edited output XML string.

Thanks in advance!

Dave

A: 

It seems to me that you could use XSLT to transform the XML into XHTML to include in the document. Once the user has entered or updated the data, you could then transform it back into XML for submission.

I haven't done XSLT on the client side, but apparently it's supported fairly generally.

andrewmu
A: 

It's unlikely that you'll find an out-of-the-box solution to your problem. Not because it's not a good idea, but because the problem space "edit XML data in a form" is almost undefinably huge.

A form-based editor that could edit any XML document would look a lot like the grid view of XML Spy. I'm reasonably certain that's not a solution you'd find acceptable. In order for the UI to be straightforward, you need to impose constraints on the XML's structure. What constraints? Well, that depends on your XML, and on your application's problem space.

Every time I've needed to do this, I've ended up building my own. It's fairly easy, as interactive HTML-based UI development projects go.

Robert Rossney