Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Camel中,如何在头上使用xpath拆分路由_Xpath_Apache Camel - Fatal编程技术网

在Camel中,如何在头上使用xpath拆分路由

在Camel中,如何在头上使用xpath拆分路由,xpath,apache-camel,Xpath,Apache Camel,正如标题所示,我有一个带有标题的路由,其中包含一些xml,类似于以下作为字符串的片段 <files> <image_file1>image.png</image_file1> <image_file2>image.png</image_file2> </files> 我使用以下方法找到了解决方案:- from(myIncomingQueue) .setBody(header("myHeaderWithXml

正如标题所示,我有一个带有标题的路由,其中包含一些xml,类似于以下作为字符串的片段

<files>
  <image_file1>image.png</image_file1>
  <image_file2>image.png</image_file2>
</files>
我使用以下方法找到了解决方案:-

from(myIncomingQueue)
    .setBody(header("myHeaderWithXml"))
    .convertBodyTo(String.class, "utf-8")
    .split(xpath("//*[local-name()='files']/*"))
        .setHeader("FilePropertyToRetrieve", xpath("local-name(//*)").stringResult())
        .setBody(header("CamelOriginalBody"))
        .to(myFileDownloadQueue)
.routeId("COMMON-CON-Attachment_Router-Id");

但出于学习目的,我仍然想知道,是否有一种方法可以做到这一点,而不必将标题移动到正文中,然后再进行反向操作?

是的,如果您阅读了有关xpath的文档,请访问:-然后查看在标题上使用xpath的部分

相似的东西

  .split(xpath("//*[local-name()='files']/*", "myHeaderWithXml"))

谢谢@Claus,我确实读了那一页,完全错过了javadsl行的那一行文本,确实读了它周围的所有内容,因此没有意义。感谢您指出:)我今天添加了java行。但是ppl不应该认为XML和Java DSL 100%基于同一个模型,所以在其中一个模型中可以做的一切都可以在另一个模型中做。感谢Claus,我对这一点非常陌生,所以还不能100%确定所有这些约定,不幸的是,我们使用的是2.09版,所以现在还需要使用我的工作。再次干杯
  .split(xpath("//*[local-name()='files']/*", "myHeaderWithXml"))