Logstash XML xpath function like PHP $father->children()

I'm searching if in logstash exist a xpath function like the one in PHP to get the child of a node without knowing the name.

Thanks to everyone

"without knowing the name" -- the name of the parent or the name of the child? Anyways, if you start with

input { generator { count => 1 lines => [ '<e1><e2><a /><b>foo</b><c>bar<d>baz</d></c></e2></e1>' ] } }

and use an xml filter

    xml {
        source => "message"
        store_xml => false
        xpath => {
            "/*/*/*/node()" => "children"

then you will get

  "children" => [
    [0] "foo",
    [1] "bar",
    [2] "<d>baz</d>"

"/*/*/*/text()" will result in

  "children" => [
    [0] "foo",
    [1] "bar"

"/*/*/*" will result in

  "children" => [
    [0] "<a/>",
    [1] "<b>foo</b>",
    [2] "<c>bar<d>baz</d></c>"

It is unclear what you are asking for since you have not explained what the PHP children function does.

1 Like

Thanks Badger!
Yes i mean the name of the child.
I think the one i need is the node().
Thank you i try it later

Worked like i need it! Thank you!

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