Issue parsing xml

Hi

I have an xml with format as below:

<DummyXML xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:abc="http://www.abc.com/xml/abc" xmlns:def="http://www.def.com/xml/def">
<Transaction>
	<abc:abcTransaction>
		<abc:BuildNumber>3.106.0.0</abc:BuildNumber>
		<abc:OnlineStatus>0</abc:OnlineStatus>
		<abc:TransactionType>15</abc:TransactionType>
		<abc:WorkstationLocation>SS</abc:WorkstationLocation>
		<abc:ExternalSystem>
			<abc:SequenceNumber>1234567890</abc:SequenceNumber>
		</abc:ExternalSystem>
		<def:RFN>9876543210</def:RFN>
	</abc:abcTransaction>
</Transaction>
</DummyXML>

I need to extract RFN field from the xml. Below is the snippet of the logstash I have written:

xml {
				source => "SourceMessage"
				remove_namespaces => "true"
				xpath => ["/DummyXML/Transaction/def:RFN/text()", "RFN"]
}

But logstash fails when parsing this file. Below is the snippet of the error that I am getting:

[2019-04-03T14:57:43,373][FATAL][logstash.runner ] An unexpected error occurred! {:error=>#<Nokogiri::XML::XPat
h::SyntaxError: /DummyXML/Transaction/def:RFN/text()>,

Can anyone please help me in this.

Thanks

Try

xpath => ["/DummyXML/Transaction/abcTransaction/RFN/text()", "RFN"]

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