Solved

How to serialize a generic JavaScript object to XML

Posted on 2009-05-07
2
260 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now