0

I am getting the following xml response from amazon after uploading a file :

#document
<PostResponse>
    <Location>https://xyz.s3.amazonaws.com/0c8a8.gdf</Location>
    <Bucket>xyz</Bucket>
    <Key>test.pdf</Key>
    <ETag>"abc"</ETag>
</PostResponse>

I have followed the answer from the following post : How to parse XML using jQuery? and tried to get the value of Key as follows :

            $xml = $( $.parseXML( data ) );
            $value = $xml.find("Key").text();

But I am getting empty string. How can I get the value of Key ?

Community
  • 1
  • 1
Rumel
  • 319
  • 1
  • 3
  • 19
  • 1
    It works fine with me on the Chrome 50 console ( replacing `data`with the literal string content you have presented [dquotes escaped, of course ...]). What is the exact content of your `data` variable? – collapsar Apr 27 '16 at 17:29
  • I write in chrome with console.log() and got the above value. Is #document at the top causing problems ? – Rumel Apr 27 '16 at 17:32
  • 1
    It doesn't with me. However, try to call `$value = data.find("Key").text();` in your callback and check the result. – collapsar Apr 27 '16 at 17:33

0 Answers0