0

I am attempting to parse XML to grab the value with delivery=streaming via Jquery and Javascript, and I am coming up short.

How can I do this with some Jquery code? I feel I'm so close, yet so far.

<MediaFiles>
    <MediaFile delivery="progressive" bitrate="3253252" type="video/mp4"><![CDATA[ https://file.mp4 ]]></MediaFile>
    <MediaFile delivery="streaming" bitrate="3253252" type="application/x-mpegURL"><![CDATA[ https://playlist.m3u8 ]]></MediaFile>
</MediaFiles>
$.ajax({
            type: 'get',
            url: 'https://getxml.com?cb=' + new Date().getTime(),
            datatype: "xml",
            success: function(data) {
                console.log(data);
                var mediaFiles = [];
                $(data).find("MediaFile").each(function() {
                    mediaFiles.push($(this).text());
                });
            }
        })

1 Answer 1

0

You have a typo in the datatype; it should be dataTypeinstead.

And, since you want to filter mediafiles with delivery="streaming", you can use this:

$(data).find('MediaFile[delivery="streaming"]')
1
  • Works great! I thought I had tried that at one point, but I guess I didn't! :)
    – Joe
    Commented Jul 9 at 23:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.