Solved

How to serialize a generic JavaScript object to XML

Posted on 2009-05-07
2
262 Views
Last Modified: 2012-05-06
Does one of the mainstream JavaScript libraries (YUI, jQuery, Dojo) provide a way to serialize a JavaScript object to XML (as text)?

Note: I'd like to transform a generic JavaScript object in general, not just a DOM.
0
Comment
Question by:avernet
2 Comments
 
LVL 12

Accepted Solution

by:
alien109 earned 125 total points
ID: 24332004
not mainstream, however and I haven't tested it - but thought I'd throw it your way anyway...
http://svn.mirekrusin.com/pub/javascript/to_xml/trunk/to_xml.js
0
 
LVL 1

Author Comment

by:avernet
ID: 24352094
@alien109 Thank you for the link! I found a few problems with this code, but it is a good start. I put some comments below in case the author finds this, or if someone wants to improve on this:

* No license is mentioned. (I will try to contact the author about it.)
* Doesn't handle arrays well. (It creates elements <1>, <2>... )
* Fails when an object has a property which value is undefined. I.e. the property exists, but its value is undefined.

Still, it's some great code to start with.

Alex
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jQuery Validate 4 36
Delay Form Submission without touching existing code? 5 22
Jquery GMAP3 Hierarchy 1 24
Jquery 2 10
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question