i am parsing XML using jQuery like this
my xml:Code:$(document).ready(function(){ $.ajax({ type: "GET", url: "list.xml", dataType: "xml", success: parseXml, error: err }); }); function err(xhr, reason, ex) { $('#output').append(reason); } function parseXml(xml){ $(xml).find("entry").each(function(){ $("#output").append($(this).attr("name") + " | " + $(this).find("email").text() + " | " + $(this).find("score").text() +"<br />"); }); }
my output looks likeCode:<?xml version="1.0" encoding="iso-8859-1"?> <data> <entry name="John Doe"> <email>john.doe@yahoo.com</email> <score>88</score> <Date>1/13/2009</Date> </entry> <entry name="GI Jane"> <email>g.jane@gmail.com</email> <score>104</score> <Date>1/13/2011</Date> </entry> <entry name="Joe Smith"> <email>joe.s@hotmail.com</email> <score>100</score> <Date>9/13/2010</Date> </entry> </data>
question: i want to output only those that score 100 or aboveCode:John Doe | john.doe@yahoo.com | 88 GI Jane | g.jane@gmail.com | 104 Joe Smith | joe.s@hotmail.com | 100
what is the best way to go about this? should i push elements into an array and compare those results?
can i somehow write the comparison into the parsing?
Code:function parseXml(xml){ $(xml).find("entry").each(function(){ $("#output").append($(this).attr("name") + " | " + $(this).find("email").text() + " | " + $(this).find("score").text() +"<br />"); }); }



Reply With Quote

Bookmarks