Take the 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
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 –  Laurent 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 at 12:08
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.