When parsing XML with jquery, how can we pass the current node from within each() to another functio
Posted
by Johusa
on Stack Overflow
See other posts from Stack Overflow
or by Johusa
Published on 2010-03-11T20:14:53Z
Indexed on
2010/03/11
20:19 UTC
Read the original article
Hit count: 132
Say we have an XML document with many book nodes...
When parsing XML with jquery, how can i pass the current node from each() iteration to another function that will do some stuff until something is reached and then go back to the previous function (passing along the current node from this function back to the first function)?
Here something more descriptive (this is just an example out of my head, not accurate):
function MyParser(x1,x2,dom) { // if i am called by anotherFunction(thisNode) proceed from the passed node
dom.find('book').each(function() { var Letter = thisNode.find(author).charAt(0); if(x1 == Letter) { // print everything till the next letter (x2) anotherFunction(thisNode) }
} }
function anotherFunction(x2,thisNode) { //continue parsing here until you reached x2 //when x2 is reached, return to previous function passing again the current node }
© Stack Overflow or respective owner