我正在查詢Microsoft Office SharePoint Server搜索服務以將一些結果寫入Web部件。我的查詢工作正常,但在解析通過JQuery的XML響應時遇到了一些麻煩。使用JQuery解析XML
下面是
<ResponsePacket xmlns="urn:Microsoft.Search.Response">
<Response domain="QDomain">
<Range>
<StartAt>1</StartAt>
<Count>1</Count>
<TotalAvailable>1</TotalAvailable>
<Results>
<Document xmlns="urn:Microsoft.Search.Response.Document">
<Action>
<LinkUrl fileExt="aspx">https://mysite.domain.inc:443/Person.aspx?guid=4A4F27E2 9C99 4866 BB08 DE494475A4E7</LinkUrl>
</Action>
<Properties xmlns="urn:Microsoft.Search.Response.Document.Document">
<Property>
<Name>TITLE</Name>
<Type>String</Type>
<Value>Smith, Joseph</Value>
</Property>
<Property>
<Name>RANK</Name>
<Type>Int64</Type>
<Value>873</Value>
</Property>
<Property>
<Name>SIZE</Name>
<Type>Int64</Type>
<Value>0</Value>
</Property>
<Property>
<Name>DESCRIPTION</Name>
<Type>String</Type>
<Value>Hi guys!</Value>
</Property>
<Property>
<Name>WRITE</Name>
<Type>DateTime</Type>
<Value>2009 07 31T03:00:24 04:00</Value>
</Property>
<Property>
<Name>PATH</Name>
<Type>String</Type>
<Value>https://mysite.domain.inc:443/Person.aspx?guid=4A4F27E2 9C99 4866 BB08 DE494475A4E7</Value>
</Property>
<Property>
<Name>JOBTITLE</Name>
<Type>String</Type>
<Value>Programmer</Value>
</Property>
</Properties>
</Document>
</Results>
</Range>
<Status>SUCCESS</Status>
</Response>
</ResponsePacket>
我想拿到冠軍,即史密斯,約瑟夫和JOBTITLE即程序員使用JQuery XML響應。
我開始:
$(xml).find('Properties').each(function(){
//not sure how to get the ones I want, use an indexer?
});
舊ASMX樣式的Web服務,您可能要添加此代碼假定XML是文檔的一部分。如果沒有,你將不得不爲這個代碼工作$(xml)。 – SolutionYogi 2009-09-01 15:16:55
謝謝。現在會更新 – 2009-09-01 15:25:10