Hi Zubin,
How about this?
CODE
var str = "http://one,two,http://three";
var a = str.split(",").filter(function (v, i) {
return v.indexOf("http://") > -1;
});
- Ben
Hi Ben,
Here is some sample data that I pulled off my web-server by doing the following:
var url = new URL();
url.location = "http://***.***.***:****/spring-portlet-sample/PCServices?action=isalertpresent&userid=.....";
contents = url.fetch(); So the
contents variable holds the following data:
<?xml version='1.0' encoding='ISO-8859-1'?>
<response>
<alert>
<imagename>2403101233242454_iPhone_9.jpg</imagename>
<imageurl>***.***.***:****/spring-portlet-sample/ImageServer?action=viewPhoto%26imageemail=*****@gmail.com%26imagename=2403101233242454_iPhone_9.jpg%26emailAddress=gsj23@yahoo.com</imageurl>
<sgname>670</sgname>
<sender>BLAH BLAH</sender>
<upclienttype>BLAH BLAH</upclienttype>
</alert>
<alert>
<imagename>2403103242344_iPhone_10.jpg</imagename>
<imageurl>***.***.***:****/spring-portlet-sample/ImageServer?action=viewPhoto%26imageemail=*****@gmail.com%26imagename=2403103242344_iPhone_9.jpg%26emailAddress=*****@gmail.com</imageurl>
<sgname>670</sgname>
<sender>BLAH BLAH</sender>
<upclienttype>BLAH BLAH</upclienttype>
</alert>
.....
Sorry for not being clear in my previous posts, but i need to extract the URL that is contained within the <imageurl> ********</imageurl> tags and put that into a data-structure of some sort.
So this is what I attempted to do (but it doesn't quite work):
var e = contents.split("<imageurl>").filter(function (v, i) {
return v.substring("http://", "</imageurl>") > -1;
});
So the logic here is that I split the data that I received in my "contents" variable and then I attempt to extract out the URL that I need, and store that.
This doesn't quite seem to be working for me, the 'rooms' of my array are not getting populated. Please let me know what is going on.
Thanks for all the help.