2

What I'm trying to achieve is to get all the values which contain "/photovit_action" and for each of those values to be used in an img tag to display the images using the link that was provided.

This is my XML: Pastebin link

and this is my JQuery:

$.ajax({
    url: "http://test.be",
    type: "POST",
    dataType: "xml",
    data: soapMessage3,
    crossDomain: true,
    contentType: "text/xml; charset=\"UTF-8\"",
    processdata: false,
    success: function (xml) {
        $(xml).find('item').each(function () {
            var url = $(this).find("value:contains('/photovit_action')").text();
            alert(url);

            $('#test').append('<img src="http://test.be/' + url + 'canvasH(180)W(186)">');
        });
    }
});

Any ideas on how to do this?

Thanks in advance.

8
  • Try $(xml).find('item:contains("/photovit_action")').each(function () { var url = $(this).text(); $('#test').append('<img src="http://test.be/' + url + 'canvasH(180)W(186)">'); }); Commented Apr 29, 2015 at 10:41
  • Hi, I'm very close to fixing the problem, by using your answer I get this address as image source: test.be/thumbstring/photovit_action/… i need the same address, just without the "thumbstring", what changes are required for this? Commented Apr 29, 2015 at 10:48
  • is thumbstring part of the url value in the xml Commented Apr 29, 2015 at 10:52
  • also whether the url element always will have the name thumbstring Commented Apr 29, 2015 at 10:53
  • jsfiddle.net/arunpjohny/p7jvkb11/1 Commented Apr 29, 2015 at 10:56

1 Answer 1

1

In your case there is no value element so the selector is wrong

$(xml).find('item:contains("photovit_action")').each(function () {
    var url = $(this).text();
    $('#test').append('<img src="test.be/'; + url.replace('thumbstring/', '') + 'canvasH(180)W(186)">');
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.