0

I'm using spring integration to get messages off of an outgoing channel. Each message is in the following format:

<message>
  <properties>
    <property>
      <key>a</key>
      <value>b</value>
    </property>
    <property>
      <key>c</key>
      <value>d</value>
    </property>
  </properties>
</message>

For each message I want to parse value b for key a and write to disk. How can I do this in spring integration?

user1040535
  • 201
  • 1
  • 3
  • 14
  • Possible duplicate of [Java: How to read and write xml files?](http://stackoverflow.com/questions/7373567/java-how-to-read-and-write-xml-files) – sidgate Sep 29 '16 at 19:46
  • Thanks, how would I do this in spring integration? – user1040535 Sep 29 '16 at 19:47
  • How about this? http://stackoverflow.com/questions/25556624/xml-deserialization-to-pojo-using-jackson-xmlmapper – Tin Sep 29 '16 at 21:03

2 Answers2

1

There is XpathSplitter to perform some xpath against incoming document and produce sub-documents for matched parts.

There is just regular XPathTransformer to extract the part of incoming document according provided xpath.

To store to disk you should use FileWritingMessageHandler.

It's really isn't clear why that Reference Manual isn't enough to find an answer...

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
0

You can use UnmarshallingTransformer from Spring Integration, refer this official documentation.

An UnmarshallingTransformer allows an XML Source to be unmarshalled using implementations of the Spring OXM Unmarshaller. Spring’s Object/XML Mapping support provides several implementations supporting marshalling and unmarshalling using JAXB, Castor and JiBX amongst others. The unmarshaller requires an instance of Source. If the message payload is not an instance of Source, conversion will be attempted. Currently String, File and org.w3c.dom.Document payloads are supported. Custom conversion to a Source is also supported by injecting an implementation of a SourceFactory.

Sundararaj Govindasamy
  • 8,180
  • 5
  • 44
  • 77