Author Topic: Skip source if some words is found at a specific xml element  (Read 22669 times)

nuno

  • Newbie
  • *
  • Posts: 18
Hi
How can I filter to skip a source if I found an expression or part of it in a specific xml element?
Example.
Im parsing a XML file wich have these nodes:

<title>Hello!</title>
<link>www.site.com/programs/tuesdaynights/2022/02/28/</link>

I want to write only the title but if the link contains the word "programs" then skip to next text source or write a custom text.
Is it possible?

Thanks

Jan

  • Hero Member
  • *****
  • Posts: 1314
Re: Skip source if some words is found at a specific xml element
« Reply #1 on: August 16, 2022, 08:45:15 pm »
  • Using the Output template, encapsulate the 'link' element into any unique substring.
    For example, if %1% is title and %2% is link:
    %1%<<%2%>>
  • Use the Text Replacing to test if the substring contains the keyword
    Change %REGEXP%<<.*programs.*>> to %GOTONEXT%
  • Remove the substring from final text
    Change %REGEXP%<<.*>> to (nothing)

Alternatively you may apply JavaScript to the same Output template, if further filtering or conditions are required.

nuno

  • Newbie
  • *
  • Posts: 18
Re: Skip source if some words is found at a specific xml element
« Reply #2 on: August 17, 2022, 11:40:41 am »
That works!
Thank you!

nuno

  • Newbie
  • *
  • Posts: 18
Re: Skip source if some words is found at a specific xml element
« Reply #3 on: August 16, 2026, 11:40:06 pm »
  • Using the Output template, encapsulate the 'link' element into any unique substring.
    For example, if %1% is title and %2% is link:
    %1%<<%2%>>
  • Use the Text Replacing to test if the substring contains the keyword
    Change %REGEXP%<<.*programs.*>> to %GOTONEXT%
  • Remove the substring from final text
    Change %REGEXP%<<.*>> to (nothing)

Alternatively you may apply JavaScript to the same Output template, if further filtering or conditions are required.

Hi!
This is not working anymore on new versions!
How can I do this now?

Thanks

Jan

  • Hero Member
  • *****
  • Posts: 1314
Re: Skip source if some words is found at a specific xml element
« Reply #4 on: August 17, 2026, 07:52:06 am »
Yes, now, in the case of XML or JSON sources, each element is processed separately, as this better reflects the logic of working with these text sources. Therefore, text replacement is no longer applied to the resulting text composed of elements according to the template.

The proposed workaround will no longer work. We will find a better solution for your specific needs.

Jan

  • Hero Member
  • *****
  • Posts: 1314
Re: Skip source if some words is found at a specific xml element
« Reply #5 on: August 17, 2026, 06:28:46 pm »
Well, if you download current build (2026-08-17), you can do following:

  • Completely remove the workaround proposed in past. Also remove the reference to the link from the Output Template.
       
  • Type following line in the Text replacing:

    Change
    %REGEXP%(?i)www.*programs

    To
    %GOTONEXT%

Explanation:
In current build, the %GOTONEXT% and %CLEAR% commands still work as you are used to. This means that even in the case of an XML/JSON source, these commands will be reflected in the resulting text. Moreover, these command now work also if matching occurs on elements which are not included in the Output Template (so they are hidden to the listener). In near future the Text replacing will include a third 'Filter' column for optinal specification of Output/Source/Element the line will apply to, so that the behaviour can be changed by the user. If you have further questions, just let me know.

nuno

  • Newbie
  • *
  • Posts: 18
Re: Skip source if some words is found at a specific xml element
« Reply #6 on: Yesterday at 01:11:31 am »
Hi Jan,

Works like expected!
The solution in near future will help a lot!
Thank you for your help :)