# Advice needed - filtering XML

**URL:** <https://discourse.nodered.org/t/advice-needed-filtering-xml/92122>\
**Category:** General\
**Created:** [2 October 2024 08:30 UTC](https://discourse.nodered.org/t/advice-needed-filtering-xml/92122 "2024-10-02T08:30:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [2 October 2024 08:30 UTC](https://discourse.nodered.org/t/advice-needed-filtering-xml/92122/1 "2024-10-02T08:30:27Z")

</div>

Hello Good peoples,

I have a problem that id like some advice on

I am pulling from a web API to see if the worker is on shift and working.

I can pull the data no problem but I need to do is if the "shift\_on" value is true then not write the record

I have a function node to pull the 3 variables and output

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/4692505647b7fcbf9ff548bc96320de0aecb9d37.png)

which outputs

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0020ac2d40bb9316b377fc637538ecfa3844466.png)

Im banging my head against the proverbal wall here, I dont know what way to proceed

Is there a easier or better way to do this other than writing JS to do it?

Any help is appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [2 October 2024 09:06 UTC](https://discourse.nodered.org/t/advice-needed-filtering-xml/92122/2 "2024-10-02T09:06:35Z")

</div>

```auto
const output = msg.payload.users.user.reduce((acc, curr) => {
    return acc.concat({ shift_on: curr.shift_on[0], name: curr.name[0], notes: curr.notes[0] });
}, []).filter(( u ) => u.shift_on === "false")

```

EDIT: the boolean you wanted other way  
EDIT2 : and you don't have boolean but strings

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [2 October 2024 09:13 UTC](https://discourse.nodered.org/t/advice-needed-filtering-xml/92122/3 "2024-10-02T09:13:13Z")

</div>

> [@leftymuller](#):
>
> but I need to do is if the "shift\_on" value is true then not write the record

this sounds like a double negative, you want to exclude `shift_on: "true"` ?

You can use a change node with a JSONata expression:

```auto
**[shift_on != "true"]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4ee89898b6d25fcdf92085d74a785b8a59aa9b08.png)

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [3 October 2024 07:59 UTC](https://discourse.nodered.org/t/advice-needed-filtering-xml/92122/4 "2024-10-03T07:59:25Z")

</div>

Thanks Gents.

Both worked.

I am not 100% with JSONata queries yet.. still getting my head around it

I just need to find in notes and filter that too.. I will try and use match ? in JSONata

Is there a easy way to learn more about JSONata queries other than reading the website?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 January 2025 07:59 UTC](https://discourse.nodered.org/t/advice-needed-filtering-xml/92122/5 "2025-01-01T07:59:51Z")

</div>

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