Navigation

1-3 Extract values from XML data

This example introduces the EvaluateXPath processor to extract an ID value from XML data to use in constructing the URI. The XPath value is stored in a FlowFile property which is used later in InvokeHTTP to construct the document URI.

The EvaluateXPath processor currently does not support namespaces. In the ml.xml.id property below, the XPath uses a workaround to match by local-name for XML that is in a namespace.

  • https://issues.apache.org/jira/browse/NIFI-1023
  • Download Template
  • Processors:
    • GetFile – reads files from a watched directory
      • Properties
        • Input Directory: /some/path
    • EvaluateXPath - Store values from XML in FlowFile properties
      • Properties
        • Destination: flowfile-attribute
        • ml.xml.id: string(/*[local-name()='message']/*[local-name()='message_xml']/*[local-name()='id']) (custom property)
      • Settings
        • Automatically Terminate Relationships: failure, unmatched
    • PutMarkLogic
      • Properties
        • DatabaseClient Service: (your MarkLogic DatabaseClient Service)
        • URI Attribute Name: ml.xml.id
        • URI Prefix: /messages/
        • URI Suffix: .xml
      • Settings
        • Automatically Terminate Relationships: failure, success