I have this xml feed, as below:
<GSP VER="3.2">
<TM>0</TM>
<Q>blue&blue</Q>
<PARAM name="output" value="xml_no_dtd" original_value="xml_no_dtd"/>
<PARAM name="q" value="blue&blue" original_value="blue%26blue"/>
</GSP>
I then have the following jquery to iterate over this xml feed:
var queryresults = $(data).find("GSP").find("PARAM[q]");
var query = "";
$(queryresults).each(function() {
query = $(this).attr('original_value').text();
alert(query);
});
But I seem to be getting no return, how do you select a specific element with a specific attribute and then selects secondary attribute. For example
Select "<PARAM>" WITH attribute="name" AND retrieve the value="original_value"
Outcome:
query=blue%26blue
Adjust your code to look like this:
What you were trying to do with the .text() function was not necessary as the .attr() function already returns the value of that attribute.
Also, in order to find elements based on name, you could use the following:
This is will also work with other attributes.
Useful reading: http://api.jquery.com/attribute-equals-selector/