0

I know the below question is very common , but i cant help myself posting here , since am little confused of what am doing in my code ...

I am sending an AJAX request and getting XML as response , As of now am parsing it based on the tag name like below :

$(xml).find('Details').each(function(){
                        //email=$(this).find('Email').text();
                         $tbl.append($('<tr>').append(

                             $('<td>').text($(this).find('name').text()),
                             $('<td>').text($(this).find('LastName').text()),
                             $('<td>').text($(this).find('City').text()),
                             $('<td>').html("<a href='insert.jsp?email="+$(this).find('Email').text()+"&mode=Search"+" ' >"+$(this).find('Email').text()+"</a>"),
                             $('<td>').html("<a href='MyServlet?email="+$(this).find('Email').text()+"&mode=Delete"+" ' >"+"Delete"+"</a>")
                             ));
                }); 

The functionality what am trying to do is absolutely working fine ,

Problem :

How to parse the XML response dynamically without knowing the tag name or the parent ?

i referred the below links for that : [XML Parsing with jQuery]

And i have to use only jquery : any kind of help is appreciable .. Thank You

2 Answers 2

1

Take a look through the Traversing API

There are quite a few functions where you can parse and move through the XML without actually knowing the tags. Some key ones for you would be children() next() siblings() and as you already know each()

Sign up to request clarification or add additional context in comments.

Comments

0

I think this might help you, do check the jquery plug-in and also basic jquery-xml-parser.

1 Comment

thanks for the response , am not looking for how to load in table , what am looking is how to parse XML without knowing the root or child elements

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.