Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I created a small library to parse xml to javascript. Can anyone tell me if the design is correct for a library or if there is a better technique?

I wrote a small Usecase example here. You can find the code here

Edit

(function (window, undefined) {
    var X2J = {
        //public method
        parseXml: function (xmlDocument, xpathExpression) {
            //private method
            var isObjectEmpty = function (obj) {}; 
            var GetChildNode = function (domElement) {};
            //... 
        }, 
        //public method 
        getValue: function (jNode, name, index, default_value) {},
        //...
    };
    window.X2J = X2J;
} (window));

Usage:

var x2jObj = null;
$.get('shows.xml', function (xmlDocument) {
    x2jObj = X2J.parseXml(xmlDocument); //X2J.parseXml(xmlDocument, '/');         
    //x2jObj is called jNode   
    console.log('x2jObj populated', x2jObj);
    console.log('To get name "One Piece (US)"', X2J.getValue(x2jObj[0].Results[0].show[1], 'name'));
});
share|improve this question

closed as off-topic by konijn, rolfl, syb0rg, 200_success, kleinfreund Feb 2 at 10:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question must contain working code for us to review it here. For questions regarding specific problems encountered while coding, try Stack Overflow. After getting your code to work, you may edit this question seeking a review of your working code." – konijn, rolfl, syb0rg, 200_success, kleinfreund
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
This question is off-topic according to the FAQ - we can review a specific piece of code but not provide advice on "higher-level architecture and design of software systems" - codereview.stackexchange.com/faq –  this.lau_ May 14 '12 at 13:22
1  
You seem to be using jquery, so this might be interresting: api.jquery.com/jQuery.parseXML –  bennofs Aug 1 '13 at 12:08
    
I second the opinion of @Laurent, this is not working code. Other than,the use of an IIFE is correct design. I would not be thrilled to have to write ` X2J.getValue(x2jObj[0].Results[0].show[1]` though. –  konijn Feb 1 at 23:57
add comment