Note that there are some explanatory texts on larger screens.

plurals
  1. POfor loop randomly crashing on certain iterations
    primarykey
    data
    text
    <p>there must be someone out there who can spot my error! I'm parsing an xml feed and running through a loop to get certain items on the page:</p> <pre><code>www.highlandradio.com/feed/ </code></pre> <p>I am encountering an error on the line where I am setting the variable mp3Test. All I want to do is to set it equal to the url attribute of the enclosure tag (if it exists). This is why I am including the test to check if each item has an enclosure tag, if it does I am setting it to be equal to the url tag but if it doesn't I am setting it to be equal to 'null.mp3' for now. When running through the loop I am getting the correct numbers for a certain amount and then on some iterations of the loop, i crashes. I am using titanium and so am not getting any proper error messages. It simply highlights the line where I set up mp3Test and says to debug the current instruction pointer. I'm going crazy with this. Please help. </p> <pre><code>var url="http://www.highlandradio.com/feed/"; var xhr = Titanium.Network.createHTTPClient(); xhr.onload = function() { // Data is returned from the blog, start parsing var doc = this.responseXML.documentElement; // begin looping through blog posts var items = doc.getElementsByTagName("item"); var enclosure = doc.getElementsByTagName("enclosure"); console.log("NEWEST Enclosure Length -----------"+enclosure.length); for (var i = 0; i &lt; items.length; i++) { var itemsEnclosureLength=items.item(i).getElementsByTagName("enclosure").length; var itemsEnclosureExists=items.item(i).getElementsByTagName("enclosure"); console.log("EXISTs ----------------------------------"+ itemsEnclosureExists); console.log("Newest ENCLOSURE LENGTH ---------------------- [ "+i+ " ]" + itemsEnclosureLength); var str=items.item(i).getElementsByTagName("content:encoded").item(0).text; console.log("STRING TEST "+ str); var patt1=/([a-z\-_0-9\/\:\.]*\.(jpg|jpeg|png|gif))/i; var urlMatch = str.match(patt1); console.log("MATCHES TESTER -----------------------------------" + typeof urlMatch); data.push({ title: items.item(i).getElementsByTagName("title").item(0).text, leftImage: str.match(patt1) !== null ? str.match(patt1)[0] : 'image_news.png', dataToPass: items.item(i).getElementsByTagName("description").item(0).text, mp3Test: itemsEnclosureLength &gt; 0 ? items.item(i).getElementsByTagName("enclosure").item(i).getAttribute("url"):'NULL.MP3' }); console.log("Check this --------------------------"+ mp3Test); } </code></pre> <p><strong>BUMP2</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload