using .each() .find() and .text() in a variable

Errormatwerve

New Member
I've been trying to figure this out for the past few hours and can't get my head round it, so I have the following function: \[code\]$("SPEECH",currentContext).each(function(){ var speaker = $("#selectSpeaker").val(); if($(this).find("SPEAKER").text()===speaker){ var line = $(this).find("LINE").text(); $("#speakers").append("<p class='speech'>" + speaker + "</p>" + "<p>" + line + "</p>"); } });\[/code\]and XML marked up like: http://pastebin.com/GhesMcayWhat I am doing is pulling in info such as \[code\]LINE\[/code\] & \[code\]SPEECH\[/code\] through XML, and it is working almost perfectly, its finding the selected \[code\]SPEAKER\[/code\], finding the \[code\]LINE\[/code\]'s associated with the speaker and outputting them. However I am finding that any \[code\]LINE\[/code\]'s that are in a row in the XML are being placed into 1 long paragraph rather than a new paragraph for each (like I want). By doing this, for the lines that are in a row, no space is placed between the end of one line and the beginning of the next, so the start and end word of lines are being joined together. From my knowledge I can say this is down to not looking for each individual line, so my thought is that using \[code\].each()\[/code\] within the variable would solve this, however I cannot seem to get it to work.Any help would be greatly appreciated! Thanks in advance.
 
Back
Top