如何使用 apigee 中的 ExtractVariables 策略读取响应返回的 xml 项目列表的第二个元素? [英] How to read 2nd element of list of xml items returned in response using ExtractVariables policy in apigee?
问题描述
我收到一个 XML 负载响应目标系统,它遵循以下结构...
I am receiving an XML payload response target system that follows the following structure...
<feed xmlns="http://www.w3.org/2005/Atom">
<title/>
<id>7c818dcd-d66a-4273-b043-ff468b956d1b</id>
<link rel="self" href="http://fhirtest.uhn.ca/baseDstu1/Patient?address=usa"/>
<link rel="next" href="http://fhirtest.uhn.ca/baseDstu1?_getpages=943fd84d-1f93-4c97-8bba-534e944e74cf&_getpagesoffset=10&_count=10&_format=xml&_pretty=true"/>
<link rel="fhir-base" href="http://fhirtest.uhn.ca/baseDstu1"/>
</feed>
并且我正在尝试使用提取变量策略来获取 <link>
标签的 href 属性值,其中属性 rel="next".
and am trying to use an Extract Variables policy to obtain the value of the href attribute of <link>
tag where attribute rel="next".
以下是我编写的提取变量策略,用于提取第一个 标签的属性 href 值.
Following is the Extract variable policy i have written that extracts value of attribute href of first <link>
tag.
<ExtractVariables name="ReadLinkURLs">
<Source>response</Source>
<XMLPayload>
<Namespaces>
<Namespace prefix="patient">http://www.w3.org/2005/Atom</Namespace>
</Namespaces>
<Variable name="href" type="string">
<XPath>/patient:feed/patient:link/@href</XPath>
</Variable>
</XMLPayload>
<VariablePrefix>pagingpatient</VariablePrefix>
</ExtractVariables>
变量 'href' 设置为字符串 "http://fhirtest.uhn.ca/baseDstu1/Patient?address=usa",即第一个值.您能否建议我为读取 <link>
元素的 href
属性值而必须做出的更改,其中 rel="next"
.提前致谢.
The variable 'href' is set to the string "http://fhirtest.uhn.ca/baseDstu1/Patient?address=usa", i.e the first value. Can you please suggest the changes i have to make to read the href
attribute value of that <link>
element in which rel="next"
. Thanks in advance.
推荐答案
我不知道 apigee,但 XPath 谓词表达式将 元素限制为仅那些具有
rel
属性值等于 "next"
是 [@rel='next']
.因此,您的整个 XPath 表达式应如下所示:
I don't know about apigee, but the XPath predicate expression to restrict <link>
elements to only those having rel
attribute value equals "next"
is [@rel='next']
. So, your entire XPath expression should look about like this :
<XPath>/patient:feed/patient:link[@rel='next']/@href</XPath>
这篇关于如何使用 apigee 中的 ExtractVariables 策略读取响应返回的 xml 项目列表的第二个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!