0

My server (nodejs) receives incoming email in html. Something like this

<div>
I am reply

<div>
On wed 20 <a href="mailto:nn@ni.com">nn@ni.com</a> wrote 
<blockquote>
This is first message
</blockquote>
</div>

</div>

How do I identify the content to be trimmed in that HTML ? Any suggestions would be really helpfull

Nikhil Ponduri
  • 290
  • 6
  • 19
  • There are lots of hide/show answers - does this help? https://stackoverflow.com/questions/4528085/toggle-show-hide-div-with-button – Nathan Dec 28 '20 at 23:32
  • @Nathan I can do hiding and showing But I need a way to find out which content to be trimmed – Nikhil Ponduri Dec 29 '20 at 02:47
  • Did the question change or something? I'm still not sure what you are asking. What's your purpose here, because you could 'trim' anything you want really. – Nathan Dec 29 '20 at 22:57
  • @Nathan The point is how I am going to identify the content that needs to be trimmed. In the above html ```I am reply``` is original message and ```This is first message``` is the previous message that is attached to the current message. So I need to trim the previous messages from the incoming html and show only the reply. How I can achieve this – Nikhil Ponduri Dec 30 '20 at 07:32
  • So you want `div > div` (the direct descendent of the reply div)? I'm not confident regex would be able to parse that, so you might have to consider a headless browser on the server as this answer explains: https://stackoverflow.com/questions/34309557/how-to-access-dom-using-node-js – Nathan Dec 30 '20 at 22:51
  • @NikhilPonduri Have you achieved this? – Bhavin Bhadani Jun 24 '21 at 08:00

0 Answers0