[xwiki-devs] Decode HTML
I have some groovy code and in it I am grabbing the value from a field and storing it in an object. When the value has spaces, it is encoded with " ". Is there a way to remove HTML encoding from a string? I looked in Util and didn't see anything. Thanks. -- View this message in context: http://xwiki.475771.n2.nabble.com/Decode-HTML-tp7589862.html Sent from the XWiki- Dev mailing list archive at Nabble.com.
I found StringEscapeUtils.unescapeJava() in import groovy.json.StringEscapeUtils. -- View this message in context: http://xwiki.475771.n2.nabble.com/Decode-HTML-tp7589862p7589863.html Sent from the XWiki- Dev mailing list archive at Nabble.com.
You can use *StringEscapeUtils.uescapeHtml(String) <http://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringEscapeUtils.html#unescapeHtml%28java.lang.String%29>* Hopping this helps. -- Sofiane On Fri, Mar 28, 2014 at 9:06 PM, DeHaynes <[email protected]> wrote:
I found StringEscapeUtils.unescapeJava() in import groovy.json.StringEscapeUtils.
-- View this message in context: http://xwiki.475771.n2.nabble.com/Decode-HTML-tp7589862p7589863.html Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
I tried that method. source.setTitle(StringEscapeUtils.unescapeHtml(NewDocumentName)); But if there are more than 2 spaces in a row, it doesn't work. It gives the following: My Process 3 In that one, there was 2 spaces between Prcess and the number 3. Any ideas why? -- View this message in context: http://xwiki.475771.n2.nabble.com/Decode-HTML-tp7589862p7589874.html Sent from the XWiki- Dev mailing list archive at Nabble.com.
On Fri, Mar 28, 2014 at 10:01 PM, DeHaynes <[email protected]> wrote:
I have some groovy code and in it I am grabbing the value from a field and storing it in an object. When the value has spaces, it is encoded with " ". Is there a way to remove HTML encoding from a string? I looked in Util and didn't see anything.
What type of field are you referring to? HTML input field? Is it a text area or an input with type=text? How do you get the value from the field? If the value contains then it's probably HTML so removing the HTML encoding will break the HTML as you can also have > or < before <em> 1 < 2</em> after I guess what you are trying to achieve is to get the plain text from an HTML content. Hope this helps, Marius
Thanks.
-- View this message in context: http://xwiki.475771.n2.nabble.com/Decode-HTML-tp7589862.html Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
I am using a String field to hold the name of the document and it's title. It works fine for the document name, but not the document Title. If there is more than one space between words in the title, it inserts a -- View this message in context: http://xwiki.475771.n2.nabble.com/Decode-HTML-tp7589862p7589934.html Sent from the XWiki- Dev mailing list archive at Nabble.com.
participants (3)
-
DeHaynes -
Marius Dumitru Florea -
Sofiane Baloul