Skip to main content
Question

How to remove a div by id or class in html template with javascriptCaller

  • September 19, 2018
  • 3 replies
  • 58 views

I have a template with differents divs with id and class, I want to delete or remove them with javascript code, I am not sure if I should use javascriptCaller or if there is another way to do that, if javascriptCaller is the right way, how can I do it? if not what the other option is and how I can do it

Thanks

3 replies

nathanatsafe
Safer
Forum|alt.badge.img+7

Hi @daniel30enero44, thanks for the question.

Can you provide a sample of your HTML template? Are you reading it as a file or is it contained within an attribute inside your workflow?

It looks like the JavaScriptCaller doesn't support objects or methods usually available in the browser, such as HTTP or DOM. This might make HTML manipulation unexpectedly difficult with the JavascriptCaller. Have you taken a look at the HTMLStripper on the FME Hub as an alternative? It might be easier to perform your HTML manipulation using FME transformers.

 

Hope this helps,

 

Nathan

siennaatsafe
Safer
Forum|alt.badge.img+10

Hi @daniel30enero44,

To remove the divs in your workspace, I'd recommend using the String Replacer and Regex. For information on Regex I would look through this Wikipedia Article on it but essentially, it allows you to search for an expression. I used this example Tester on Regex to find an expression to remove a Span with the class Hc_hotel_rate_roomRate. I would test out the Regex and place it in the String Replacer. stringreplacer.png My colleague also recommended this website for Regex Testing.

Thanks,

Sienna


arnold_bijlsma
Enthusiast
Forum|alt.badge.img+14

I had the same question, and following @siennaatsafe​'s suggestion to use the StringReplacer and some further Googling, I got to the following:

  • Mode = Replace Regular Expression
  • Text To Replace = <.*>(.*?)</.*>
  • Replacement Text = \\1

Note: this assumes you've got opening and closing tags at either end of your string

StringReplacer


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings