I have a xml file like this:
<NameValuePair>
<ParameterName>Name</ParameterName>
<ParameterValue>Maria</ParameterValue>
</NameValuePair>
<NameValuePair>
<:ParameterName>Age</ParameterName>
<ParameterValue>23</ParameterValue>
</NameValuePair>
I use xpath in filter like this:
xpath => [
"//NameValuePair/ParameterName/text()", parametername_txt,
"//NameValuePair/ParameterValue/text()", parametervalue_txt
]
But I get this in cmd console:
"parametername_txt" => [
[0] "Name",
[1] "Age"
],
"parametervalue_txt" => [
[0] "Maria",
[1] "23"
]
The I tried to use also in filter:
mutate {
add_field => {"%{[parametername_txt]}" => "%{[parametervalue_txt]}"}
}
And then I got this:
"Name,Age" => "Maria,23"
But I want to get something like this:
"Name" => "Maria",
"Age" => "23"
I know that I can get each element doing this:
mutate {
add_field => {"%{[parametername_txt][0]}" => "%{[parametervalue_txt][0]}"}
add_field => {"%{[parametername_txt][1]}" => "%{[parametervalue_txt][1]}"}
}
But the number of elements is not fixed. I could had have 3, 4, whatever... For example:
"Name" => "Maria",
"Age" => "23",
"Address" => "ABC",
"Color" => "blue"
...
How can I do this? I got stuck in this problem :-( Can anyone help me?