0
我正在爲用戶使用JavaScript工具來檢索使用預定義值的搜索結果。其中一個預定義值包含一個包含&符號的短語。我無法弄清楚如何格式化字符串,以便查詢Web服務將返回一個值。帶搜索符號的SharePoint搜索Web服務
var eventCat = "Conference & Events";
var dateQ = "(DateStart>='" + startDate + "' AND DateStart<='" + endDate + "') AND ";
var eventQ = " EventCategory='" + eventCat + "' AND ";
var q = "SELECT Title,Path,Description,Write,Rank,Size,DateStart,DateEnd,EventCategory,GroupOnly FROM SCOPE() WHERE ";
q += dateQ + eventQ + " GroupOnly=false AND (\"SCOPE\"='Sales Marketing & Excellence Events')";
var queryText = makeQuery(q);
makeQuery
創建XML所需要查詢的Web服務,轉換&符號來&,<到<和> >。
<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'>
<Query>
<Context>
<QueryText language='en-US' type='MSSQLFT'>
SELECT
Title,Path,Description,Write,Rank,Size,DateStart,DateEnd,EventCategory,GroupOnly
FROM
SCOPE()
WHERE
(DateStart>='2014-09-28T00:00:00Z' AND DateStart<='2014-11-09T23:59:59Z') AND
EventCategory='Conference & Events' AND
GroupOnly=false AND
("SCOPE"='Sales Marketing & Excellence Events')
</QueryText>
</Context>
<IncludeSpecialTermResults>true</IncludeSpecialTermResults>
</Query>
</QueryPacket>
可正常工作時eventCat有一些其他的價值像所有的,但是當我把上面的查詢時,SharePoint返回錯誤:An error occurred while parsing EntityName
。
我試過用各種替代方法替換&符號,我所做的一切都沒有改變。什麼是正確的格式發送?