开发者

XML <--> HTML Form: Generating HTML form to edit XML?

开发者 https://www.devze.com 2023-01-20 09:46 出处:网络
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 o开发者_如何学编程bject, dynamically

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 o开发者_如何学编程bject, 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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消