I am querying the Microsoft Office SharePoint Server Search Service to write some results into a web part. I have the query working correctly but am having some trouble parsing the xml response via JQuery.
Below is the XML response :
<document>
<properties>
<Property>
<Name>p1</Name>
<Type>String</Type>
<Value>blue</Value>
</Property>
<Property>
<Name>title</Name>
<Type>string</Type>
<Value>titreA</Value>
</Property>
</properties>
</document>
<document>
<properties>
<Property>
<Name>p1</Name>
<Type>String</Type>
<Value>blue</Value>
</Property>
<Property>
<Name>title</Name>
<Type>string</Type>
<Value>titreB</Value>
</Property>
</properties>
</document>
<document>
<properties>
<Property>
<Name>p1</Name>
<Type>String</Type>
<Value>green</Value>
</Property>
<Property>
<Name>title</Name>
<Type>string</Type>
<Value>titreC</Value>
</Property>
</properties>
</document>
<document>
<properties>
<Property>
<Name>p1</Name>
<Type>String</Type>
<Value>red</Value>
</Property>
<Property>
<Name>title</Name>
<Type>string</Type>
<Value>titreD</Value>
</Property>
</properties>
</document>
How can i retrieve p1 value, and number of occurence of this value ?
Like this : blue(2), green(1), red(1)
XML data can be ‘parsed’ using jQuery’s methods just like HTML. Assuming
datais the XML data.p1Value is an array of values that have a name of ‘p1’.
p1Value[0]is equal to ‘blue’.If you also want the number of occurrences, you can do this.
p1Values is an object with the value as the property name, and the occurrences as the property value.
p1Value['blue']is equal to 2.