大家好 !我有一个jquery,它在共享点服务器上命中一个Query并以XML文档的形式获取结果,如下所示:
<?xml version="1.0" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<QueryResponse xmlns="urn:Microsoft.Search">
<QueryResult>
<ResponsePacket xmlns="urn:Microsoft.Search.Response">
<Response>
<Range>
<StartAt>1</StartAt>
<Count>1</Count>
<TotalAvailable>1</TotalAvailable>
<Results>
<Document xmlns="urn:Microsoft.Search.Response.Document">
<Action>
<LinkUrl>http://ishaan1519:1234/Lists/Discussions/where are 401k benefit investment prospectus</LinkUrl>
</Action>
<Properties xmlns="urn:Microsoft.Search.Response.Document.Document">
<Property>
<Name>TITLE</Name>
<Type>String</Type>
<Value>where are 401k benefit investment prospectus</Value>
</Property>
<Property>
<Name>PATH</Name>
<Type>String</Type>
<Value>http://ishaan1519:1234/Lists/Discussions/where are 401k benefit investment prospectus</Value>
</Property>
</Properties>
</Document>
</Results>
</Range>
<Status>SUCCESS</Status>
</Response>
</ResponsePacket>
</QueryResult>
</QueryResponse>
</soap:Body>
</soap:Envelope>
我需要用标题和链接路径填充文本字段(#output)
使用此功能
$(xData.responseXML).find("QueryResult").each(function () {
var x = $("<xml>" + $(this).text() + "</xml>");
x.find("Document").each(function () {
url = $("Action>LinkUrl", $(this)).text();
title = $("Title", $(this)).text();
$("#output").append("title: " + title + " - LinkUrl: " + url);
});
我可以获取LinkUrl,但标题为
null
请帮助我在文本字段中填充title。从
<Property>
<Name>TITLE</Name>
<Type>String</Type>
<Value>where are 401k benefit investment prospectus</Value>
</Property>
提前致谢!
最佳答案
没有元素标题。 TITLE在元素中title = $("Property>Name", $(this)).text();