Help!! JQuery XML Parsing and HTML rendering

Posted by Reachansari under jQuery on 8/12/2011 | Points: 10 | Views : 1673 | Status : [Member] | Replies : 0
Hi All,
Greetings!! I am new to JQuery and hence i seek experts assistance for a solution.
In the below XML i have the Category "Sales" 2 times and "Products" 4 times. I need to group those Categories as single "Sales" and "Products" and the corresponding number of URLMenu should come under those single categories.


<z:row Category="Sales " URLMenu="" />
<z:row Category="Products" URLMenu="" />
<z:row Category="Sales "URLMenu="" />
<z:row Category="Products" URLMenu="http://www.Financial.come" />
<z:row Category="Products" SubCategory="International" URLMenu="United States" />
<z:row Category="Products" SubCategory="International" URLMenu="Australia" />

JQuery Function

$(document).ready(function () {
var thisHtml = '';
var url = 'Data.xml';
$.get(url, function (d) {
thisHtml += '<ul>';
$(d).find('z\\:row').each(function () {
var xml_category = $(this).attr('Category');
var xml_URLwMenu = $(this).attr('URLMenu');
thisHtml += '<li>' + xml_category + '</li><ul><li><a >' + xml_URLwMenu + '</a></li></ul>';
thisHtml += '</ul>';

Expected Result:

. Sales
. Products
o International
? United States
? Australia

Also note that "Products" has subcategory "International" in XML and it also needs to be listed.

Could you please help me in re-writing the JQuery function to support the expected result?

As of now i am getting all the XML "category" with the number of times the "Products" and "Sales" are present.

I am new to JQuery and have been breaking my heads for days. Your help will be highly appreciated.



(No response found.)

Login to post response