Parse XML


For data Order Event, below are the values that are coming in XML:

OrderType : Direct
OrderDate : 20190401

But the XML contains the field name and field values in below format:


Had it been ordertype and order date in tags I would have fetched it easily but here these are embeded in FieldName and FieldValue tags.

If I need to fetch order date then how should I proceed.


    xml {
        store_xml => true
        target => "[@metadata]"
        source => "message"
    ruby {
        code => '
            k = event.get("[@metadata][FieldName]")
            v = event.get("[@metadata][FieldValue]")
            k.each_index { |x|
                event.set(k[x], v[x])

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.