# convert html to text

**URL:** <https://forum.servoy.com/t/convert-html-to-text/9853>\
**Category:** Classic Servoy\
**Created:** [November 7, 2008, 2:19pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853 "2008-11-07T14:19:04Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [November 7, 2008, 2:19pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/1 "2008-11-07T14:19:04Z")

</div>

Hi,

I have a text\_area field and I like to be able to format the content, so html or rtf seems to be the most convenient display type. But now I like to convert the formatted content to text for export reasons. Is there any way to do it?

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [November 7, 2008, 3:34pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/2 "2008-11-07T15:34:51Z")

</div>

Try this, it should help:

```auto
//Returns the escaped markup text (HTML/XML)
var escapedText = utils.stringEscapeMarkup('<html><body>escape me</body></html>')

```

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [November 10, 2008, 11:23am UTC](https://forum.servoy.com/t/convert-html-to-text/9853/3 "2008-11-10T11:23:44Z")

</div>

Hi Nicola,

sorry it doesn’t help. All what I get out is this:

> “escape me”

What I would like to see is this

> **this sould be bold**  
> _and this maybe italic_

---

<div class="post-metadata">

**Author:** ![Joas](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/joas/32/5095_2.png) [@Joas](https://forum.servoy.com/u/Joas)\
**Post date:** [November 10, 2008, 12:34pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/4 "2008-11-10T12:34:09Z")

</div>

So you just want the plain text without formatting, right?

To get this, make sure your the htmlarea has a name and do:```  
elements.myname.getAsPlainText();

```auto

```

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [November 10, 2008, 12:40pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/5 "2008-11-10T12:40:18Z")

</div>

Hi Joas,

nop, I want the formatted text. Thats why I have an html area, so that the user can format the text and export it.

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [November 10, 2008, 12:50pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/6 "2008-11-10T12:50:38Z")

</div>

> irenem:  
> Hi Joas,
> 
> nop, I want the formatted text. Thats why I have an html area, so that the user can format the text and export it.

Ok, but export it in which format? The standard for formatted text is HTML or RTF so to which one do you want to convert it?

---

<div class="post-metadata">

**Author:** ![Joas](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/joas/32/5095_2.png) [@Joas](https://forum.servoy.com/u/Joas)\
**Post date:** [November 10, 2008, 12:50pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/7 "2008-11-10T12:50:57Z")

</div>

Hmmm, I don’t really get the problem then. If you want to keep the formatting, why can’t you just use the html from the dataprovider?

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [November 10, 2008, 1:07pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/8 "2008-11-10T13:07:55Z")

</div>

I use the wordplugin from it2b. If I replace the bookmark with the content of the html-area I get the whole code.

```auto
<html>
  <head>

  </head>
  <body>
    <p style="margin-top: 0">
      Zandweg 69 B
    </p>
    <p style="margin-top: 0">
      3454 JW <b>De Meern</b>
    </p>
  </body>
</html>

```

What I want to see is this:

zandweg 69b  
3454JW **De Meern**

---

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [November 10, 2008, 3:43pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/9 "2008-11-10T15:43:14Z")

</div>

if it’s only to modify (some) text to bold, you can use plugins.it2be\_word.toggleBold() for that with the Word plug.  
I’dd say use the getAsPlainText() function and apply plugins.it2be\_word.toggleBold() .

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [November 10, 2008, 9:50pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/10 "2008-11-10T21:50:58Z")

</div>

Which version do you use?

If it is the IT2BE Word Plug-in for Servoy 4 Eclipse the by Karel suggested methods will not work due to new libraries.

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [November 10, 2008, 10:07pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/11 "2008-11-10T22:07:25Z")

</div>

Hi Marcel,

The version for Servoy 4 is the version I use. Is there any other way to do this? Or will it be possible in the future?

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [November 10, 2008, 10:33pm UTC](https://forum.servoy.com/t/convert-html-to-text/9853/12 "2008-11-10T22:33:33Z")

</div>

See my reply on our forum irene: [http://www.it2be.com/index.php/forum?ta … 1433#p1433](http://www.it2be.com/index.php/forum?task=viewtopic&pid=1433#p1433)

I see several ways to solve this, depending on what you need to do.
