本文共 3537 字,大约阅读时间需要 11 分钟。
Sam Collett wrote:
我历尽千辛万苦,但是也没有找到使用jQuery能够序列化XML的方法。是不是我没有找到,或者需要我从头开始写一个新的插件($.fn.serializeXML)
我知道Firefox有XMLSerializer()这么一个方法,但是对于IE、Safari、Opera呢?我想的一种能够支持多种序列化是比较好的:
JS Object <--> XML <--> JSON <--> JS Object 实质上,jQuery提供了一个插件,能够实现XML的序列化问题:
Trackback:
原文:
Sam Collett wrote:
> On 02/10/06, Mark Gibson <> wrote:>> Hello,>> I've search high and low, but can't find a method of serializing XML>> with jQuery. Have I missed something, or should I start writing a>> new plugin? ($.fn.serializeXML)>>>> I know that firefox has XMLSerializer(), any ideas for IE, Safari,>> Opera? Maybe just a hand coded JS serializing routine?> > I don't think there is any way of serializing XML in jQuery without> resorting to a plugin (I don't know of any plugins that can do this).> > I think a multi-purpose serializer would be good:> JS Object <--> XML <--> JSON <--> JS ObjectI was specifically thinking of just serializing DOM objects to strings,
anything beyond that requires some kind of mapping.Here's a simple implementation using the XMLSerialize object:
This will need to be fleshed out for other browsers.
Does anyone know of native serialization methods in IE, Safari, Opera?
or do any of these support XMLSerialize()?- Mark Gibson
Subject: Re: [jQuery] New plugin: toXML (XML serializer) Hi,> I've submitted the XML serializer plugin to the wiki:
>>Since Trac doesn't have a possibility to discuss such things before editing
the Webpage I'd like to post two other Variants here for discussion:Simulate XMLSerializer globally and use it always - change the serialization
function on first call to distinguish between IE and others.---
----
I admit, that the two suggestions might not be to easy to understand. I like
to play with functions as values :-)At least the first one provides a more general solution by simulating
XMLSerializer and both of them are faster after the first call. That might be a criterium if you work with large Datasets. If performance is imortant to you, you might also consider to replace the calls to each() with for-loops.Christof
转载地址:http://mqzvi.baihongyu.com/