[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to serialize a generic JavaScript object to XML

Posted on 2009-05-07
2
Medium Priority
?
280 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

834 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