I have a xml that is not parsing correctly unless I prettify the xml. XML tags can be a new line or same line with the last end tag, and does not have indentation for it. but i tried with prettify it worked fine. can we achieve this with out prettify or do we need to prettify the xml befor we process with logstash? Is there a way that i can handle with logstash?
Below is my xml
<?xml version="1.0" encoding="utf-8"?><batch_upload><batches><batch><id>00010</id><title>Batch Title</title><description><![CDATA[We're one of the largest Membership organizations in the country, but we’re so much more than our legendary roadside service. We call our club's vision, mission, values, and supporting pillars "Our House" because they are the foundation for all that we do. We're working to transform life by unleashing the innovative spirit of our Team Members. We're community minded, and celebrate the growth, development and successes of our diverse Team Members. .]]></description><city>Anchorage</city><state>AK</state><zipcode>99503</zipcode><country>USA</country><parameters /><groups><group type="1">10</group><group type="1">11</group><classification type="1">12</group><group type="2" />212</group><requirements /><person><name>Person one</name><methods><method type="online">Method 1</method></methods></person></batch></batches></batch_upload>
below is my logstash config
input {
file {
path => "batches.xml"
start_position => beginning
sincedb_path => "NUL"
type => "xml"
codec => multiline
{
pattern => "|</batches"
negate => true
what => "previous"
auto_flush_interval => 1
}
}
}
filter {
if [message] == "" or [message] == "" or [message] == "\r" {
drop {}
}
xml {
store_xml => false
source => "message"
target => "message.parsed"
xpath => [
"/batch/id/text()", batch_id,
"/batch/title/text()", batch_title
]
force_array => false
}
}