RENJITHVR4
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016
02:27 AM
How to parse HTML tags by using Brightscript?
From API , we have some text with HTML tags. Actually, it is privacy policy content. So is it possible to show privacy policy content without HTML tags? But we want the Right style. Like font size and weight. Is it possible to convert HTML tags to relevant format for this? Please suggest me the best way.
For example
For example
<ol>\r\n\t<li>We use Personal Data to allow you to participate in the features on the Site, to process your registration, and to provide you with other requested content related to our content and other offerings. Click here to learn more </li></ol>
7 REPLIES 7
venkatareddy
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2018
05:08 AM
Re: How to parse HTML tags by using Brightscript?
Hi
I am also looking for same issue, if you got any solution for this. Please give me an update. Thanks in advance, hope to get response from you.
I am also looking for same issue, if you got any solution for this. Please give me an update. Thanks in advance, hope to get response from you.

speechles
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2018
10:13 AM
Re: How to parse HTML tags by using Brightscript?
Brightscript Debugger> html = "<tag>hi there<another tag/><tag2> <TAG3>MORE</tag3>"
Brightscript Debugger> ? html
<tag>hi there<another tag/><tag2> <TAG3>MORE</tag3>
Brightscript Debugger> r = CreateObject("roRegex", "<.*?>", "") : ? r.ReplaceAll(html, "")
hi there MORE
Brightscript Debugger> html = "\r\n\tHELLO \r\r\rHOW ARE YOU?"
Brightscript Debugger> ? html
\r\n\tHELLO \r\r\rHOW ARE YOU?
Brightscript Debugger> r = CreateObject("roRegex", "(\\r|\\t|\\v|\\n)", "") : ? r.ReplaceAll(html, "")
HELLO HOW ARE YOU?
Brightscript Debugger> html = "<ol>\r\n\t<li>We use Personal Data to allow you to participate in the features on the Site, to process your registration, and to provide you with other requested content related to our content and other offerings. Click here to learn more </li></ol>"
' strip html tags
Brightscript Debugger> r = CreateObject("roRegex", "<.*?>", "") : html = r.ReplaceAll(html, "")
' strip carriage return, tab, vertical tab, newline
Brightscript Debugger> r = CreateObject("roRegex", "(\\r|\\t|\\v|\\n)", "") : html = r.ReplaceAll(html, "")
Brightscript Debugger> ?html
We use Personal Data to allow you to participate in the features on the Site, to process your registration, and to provide you with other requested content related to our content and other offerings. Click here to learn more
' strip non breaking space entity
Brightscript Debugger> r = CreateObject("roRegex", " ", "") : ? r.ReplaceAll(html, "")
We use Personal Data to allow you to participate in the features on the Site, to process your registration, and to provide you with other requested content related to our content and other offerings. Click here to learn more
Brightscript Debugger> ? html
<tag>hi there<another tag/><tag2> <TAG3>MORE</tag3>
Brightscript Debugger> r = CreateObject("roRegex", "<.*?>", "") : ? r.ReplaceAll(html, "")
hi there MORE
Brightscript Debugger> html = "\r\n\tHELLO \r\r\rHOW ARE YOU?"
Brightscript Debugger> ? html
\r\n\tHELLO \r\r\rHOW ARE YOU?
Brightscript Debugger> r = CreateObject("roRegex", "(\\r|\\t|\\v|\\n)", "") : ? r.ReplaceAll(html, "")
HELLO HOW ARE YOU?
Brightscript Debugger> html = "<ol>\r\n\t<li>We use Personal Data to allow you to participate in the features on the Site, to process your registration, and to provide you with other requested content related to our content and other offerings. Click here to learn more </li></ol>"
' strip html tags
Brightscript Debugger> r = CreateObject("roRegex", "<.*?>", "") : html = r.ReplaceAll(html, "")
' strip carriage return, tab, vertical tab, newline
Brightscript Debugger> r = CreateObject("roRegex", "(\\r|\\t|\\v|\\n)", "") : html = r.ReplaceAll(html, "")
Brightscript Debugger> ?html
We use Personal Data to allow you to participate in the features on the Site, to process your registration, and to provide you with other requested content related to our content and other offerings. Click here to learn more
' strip non breaking space entity
Brightscript Debugger> r = CreateObject("roRegex", " ", "") : ? r.ReplaceAll(html, "")
We use Personal Data to allow you to participate in the features on the Site, to process your registration, and to provide you with other requested content related to our content and other offerings. Click here to learn more
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018
02:59 PM
Re: How to parse HTML tags by using Brightscript?
don't use roRegEx when simple .replace() would do; the latter is faster.
roXmlElement may be of help, if the html in question is well-formed from the point of view of XML.
roXmlElement may be of help, if the html in question is well-formed from the point of view of XML.

speechles
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018
03:26 PM
Re: How to parse HTML tags by using Brightscript?
replace doesn't do glob or grouping does it?
So would still need regex to strip the html tags and possibly the grouped \r \n \t \v. You are right though, the last part where it strips off the could've been replace.
So would still need regex to strip the html tags and possibly the grouped \r \n \t \v. You are right though, the last part where it strips off the could've been replace.
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018
02:19 PM
Re: How to parse HTML tags by using Brightscript?
i doubt actual string would have backspace literals, that's neither here (html) nor there (c source) encoding. In Roku-speak, \r\n\t would have been chr(13)+chr(10)+chr(8)

speechles
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018
03:23 PM
Re: How to parse HTML tags by using Brightscript?
chr(8) is backspace. chr(9) = \t = horizontal tab and chr(11) = \v = vertical tab. You silly rabbit.
Brightscript Debugger> ? "no"+chr(8)+chr(8)+"yes"
yes
Brightscript Debugger> ? "no"+chr(8)+chr(8)+"yes"
yes
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2018
03:15 PM
Re: How to parse HTML tags by using Brightscript?
"speechles" wrote:
chr(8) is backspace. chr(9) = \t = horizontal tab and chr(11) = \v = vertical tab. You silly rabbit.
i stand corrected.