Removing label HTML formatting from survey results?

4379
4
03-30-2016 11:38 AM
Mary_AnnSweeney
New Contributor

Using this blog post Surveys with style https://community.esri.com/groups/survey123/blog/2015/08/24/surveys-with-style#comments I added html formatting to my survey choices to make my text legible against my color scheme.

e.g. from XLSform, choices sheet. list_name, name, label, respectively

landownerUND<font color="black">Undetermined</font>

However in my Survey Results, it continues to use these labels versus the name assigned to it. Should html formatting be reserved for notes and hints only? Or can I change the appearance of choices some other way?

Thanks!

0 Kudos
4 Replies
HernandezAstorga
New Contributor

Hi everyone!!

I have a little big problem , I have  a file "File CPG (.cpg)",I try to open this in my ARCGIS10 but not let me "Invalid raster dataset. Failed to create raster layer". Any suggestions for open this file? My email is fhas33@gmail.com

Thank you 

0 Kudos
TedKowal
Occasional Contributor III

Mary, given what you gave, I assume that these fields were basically used for label formatting on a published map or report.  You now wish to use these field as data inputs elsewhere, but have html coding as part of the field.  This was an old fashion way of formatting labels.  My suggestion is to either write a script to strip the html tags or use the field calculator advanced section and write a mini script to trip the tags away from the string.

Python has a module called HTMLParser which does the very thing you are look for and a more through way of doing the stripping  the code would look something like this...

More advanced type of Python

from HTMLParser import HTMLParser
class MLStripper(HTMLParser):
  def __init__(self):
  self.reset()
  self.fed = []
  def handle_data(self, d):
  self.fed.append(d)
  def handle_entityref(self, name):
  self.fed.append('&%s;' % name)
  def get_data(self):
  return ''.join(self.fed)


def html_to_text(html):
  s = MLStripper()
  s.feed(html)
  return s.get_data()

Your examples appear to be fairly simple in nature so using the field calculator you may be able to successfully strip the tags using the following mini script :

Expression:

remove_html_tags(!YourFieldName!)

Code Block:

import re
def remove_html_tags(data):
  p = re.compile(r'<.*?>')
  return p.sub('', data)
0 Kudos
Mary_AnnSweeney
New Contributor

Realized this was in the wrong group, moved it to the correct one. Thanks.

0 Kudos
HannahFerrier
Occasional Contributor III

Good news Mary - this issue will be fixed in the next release of Survey123!!

Any HTML formatting will be stripped from your labels when they are used to create the field alias values. Or, if you prefer, you can specify your own field alias values to override the values from the label field.

Keep an eye on our blog because the next release drops soon!!

- Hannah