我正在尝试将我的Mule 3.4 CE应用程序迁移到Mule 3.6.1 CE并遇到xpath3问题。
有效载荷:
#include <stdio.h>
#include <math.h>
int main()
{
char str[100];
char *ptr;
printf("Enter the string = ");
fgets(str, sizeof(str), stdin);
ptr = str;
while (*ptr != '\0')
{
char *save;
save = ptr;
if (*ptr == ' ')
{
char *next;
for (next = ptr + 1 ; *next != '\0' ; next++, ptr++)
*ptr = *next;
ptr = save;
}
ptr++;
}
printf("Modified string = %s\n", str);
return 0;
}
xpath表达式(工作)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:itemMessage xmlns:ns2="http://test.com/messages">
<requestId>QAREQ:150623_0002</requestId>
<requestStatus>COMPLETE</requestStatus>
</ns2:itemMessage>
xpath3表达式(不工作)
#[xpath('string(//itemMessage/requestId/text())')]
欣赏任何见解。
答案 0 :(得分:2)
您的Xpath表达式似乎与XML文档不匹配。但基于XML文档,这有效:
<mulexml:namespace-manager
includeConfigNamespaces="true">
<mulexml:namespace prefix="ns2" uri="http://test.com/messages" />
</mulexml:namespace-manager>
<flow name="testFlow">
<poll doc:name="Poll">
<set-payload
value="<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns2:itemMessage xmlns:ns2="http://test.com/messages"> <requestId>QAREQ:150623_0002</requestId> <requestStatus>COMPLETE</requestStatus> </ns2:itemMessage>"
doc:name="Set Payload" />
</poll>
<logger level="INFO" message="#[xpath3('ns2:itemMessage/requestId/text()', payload, 'STRING')]" />
</flow>