Announcement Announcement Module
No announcement yet.
Convert string to XML Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert string to XML

    Hi all. This may be a silly question, however I've scoured the docs and the forum and it's not immediate obvious to me.

    I have a message entering a Spring Integration flow. The message is an XML document, represented as a String.

    I wish to convert the string to an xml Document as the first step in the flow, so that I can perform Xpath based routing etc on it. Can I do this using the inbuilt components or do I have to write some custom code?

    Incidentally, I have the xpath based routing working fine with doctype as String (xml components do on the fly conversion) but it would seem more efficient to convert it once to a Document if multiple xpath operations are applied. Is this correct?


  • #2
    Document is less efficient than String in some regards, so it all depends as usual. I wouldn't start tuning this until you have seen an actual performance or memory problem in your particular case. In fact, it might be that you want to get rid of the XPath solution before because XPath in itself isn't cheap either.

    To get back to your question, in 1.0.3 there are no converters, but writing your own using @Transformer is trivial. In 2.0 we could add support for this through the ConversionService.