gpt4 book ai didi

jquery - 从 XML 文档获取标题值

转载 作者:行者123 更新时间:2023-12-01 08:24:43 25 4
gpt4 key购买 nike

嘿大家好!我有一个 jquery,它在共享点服务器上进行查询并以 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 = $("属性>名称", $(this)).text();

关于jquery - 从 XML 文档获取标题值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4827130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com