I have a code in my application to print some data in word.
Somewhere in the code I do this:
gerarSumarioSeger = gerarSumarioSeger + |<p>| + docP.ds_assunto(0) + |</p>|
I assemble the HTML getting the data from the field in the document. Ok, not hard at all.
But, if I try to print two of the documents that have in this field the data like in the image
the word is generated with the error in image
If I remove one of the "çã" in one of the fields the error doesn't occur.
If I put a hidden field with a special character like below the error doesn't occur:
<p style="visibility:hidden;">ã</p>
If I select another document with the content in the field like bellow the error doesn't occur:
Convênio de Cooperação Geral - Sebrae e Ministério do Desenvolvimento
Social e Agrário - MDSA
I think you have to add the character set to your html, something like:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Related
I want to find elements containing name and age.
But Name can contain whitespace like "Jo hn", So I want to remove whitespace between strings.
So I made code below, but SyntaxError. How can I do this?
driver.find_elements_by_xpath('//*[#id="Nlist"]/section/ul/li/a/span[contains(text().replace(" ", ""),"' + NAME + '") and contains(.,"' + AGE + '")]')
text().replace(" ", "") is Syntax Error. Is there any method?
I need to do this when find elements because speed.
Here is the sample html used to trim the space(s) with in name and used contains to match the partial text.
<!DOCTYPE html>
<html>
<body>
<span>s upputuri-100</span>
<span>s upp uturi-100</span>
</body>
</html>
You can use translate method to replace the white space(s) with the desired char/empty. Below the xpath to get the span that contains supputuri and 100.
//span[contains(translate(.,' ' ,''),'supputuri')][contains(.,'100')]
I have a custom field with some HTML code in it:
<h1>A H1 Heading</h1>
<h2>A H2 Heading</h2>
<b>Rich Text</b><br>
fsdfafsdaf df fsda f asdfa f asdfsa fa sfd<br>
<ol><li>numbered list</li><li>fgdsfsd f sa</li></ol>Another List<br>
<ul><li>bulleted</li></ul>
I also have another non-stored field where I want to display the plain text version of the above using REGEXP_REPLACE, while preserving the carriage returns/line breaks, maybe even converting <br> and <br/> to \r\n
However the patterns etc... seem to be different in NetSuite fields compared to using ?replace(...) in freemarker... and I'm terrible with remembering regexp patterns :)
Assuming the html text is stored in custitem_htmltext what expression could i use as the default value of the NetSuite Text Area custom field to display the html code above as:
A H1 Heading
A H2 Heading
Rich Text
fsdfafsdaf df fsda f asdfa f asdfsa fa sfd
etc...
I understand the bulleted or numbered lists will look crap.
My current non-working formula is:
REGEXP_REPLACE({custitem_htmltext},'<[^<>]*>','')
I've also tried:
REGEXP_REPLACE({custitem_htmltext},'<[^>]+>','') - didn't work
When you use a Text Area type of custom field and input HTML, NetSuite seems to change the control characters ('<' and '>') to HTML entities ('<' and '>'). You can see this if you input the HTML and then change the field type to Long Text.
If you change both fields to Long Text, and re-input the data and formula, the REGEXP_REPLACE() should work as expected.
From what I have learned recently, Netsuite encodes data by default to URL format, so from < to < and > to >.
Try using triple handlebars e.g. {{{custitem_htmltext}}}
https://docs.celigo.com/hc/en-us/articles/360038856752-Handlebars-syntax
This should stop the default behaviour and allow you to use in a formula/saved search.
I'm reading an HTML web page that contains literal accented words (Spanish):
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Web page</title>
<body>
<p>Título</p>
<p>Año</p>
<p>Ángel</p>
<p>¿por qué nos vamos?</p>
</body>
I'm using HXT:
...
let doc = readDocument [ withValidate no
, withInputEncoding iso8859_1
, withParseHTML yes
, withWarnings no
, withEncodingErrors no
, withCurl []] url
...
Using the option
withInputEncoding utf8
discard those chars, getting as result the following words: Ttulo, Ao, ngel, por qu nos vamos?
Using the option
withInputEncoding iso8859_1
convert those chars to strings, getting as result words like: Rom\225ntica, Man\180s, H\233ctor. Where \225, \180 or \233 are strings, not chars.
What is the best method/way/approach to properly manage this situation in HXT and get all words without modifications?
Thanks.
I bet you already have everything you need
Prelude> putStrLn $ read "\"Rom\225ntica\""
Romántica
Looks like you are looking to result of show applied to the string, not the string itself? Note that print uses show:
Prelude> print (read "\"Rom\225ntica\"" :: String)
"Rom\225ntica"
I have a portion of HTML that looks similar to:
<table><tbody><tr>
<td><div> Text Goes Here </div></td>
<td> ... rest of table
There are no IDs, no Titles, no descriptors of any kind to easily identify the div that contains the text.
When an error occurs on the page, the error is inserted into the location where "Text Goes Here" is at (no text is present unless an error occurs). Each error contains the word "valid".
Examples: "The form must contain a valid name" or "Invalid date range selected"
I currently have the Watir code looking like this:
if browser.frame(:index => 0).text.includes? "valid"
msg = # need to get full text of message
return msg
else
return true
end
Is there any way to get the full text in a situation like this?
Basically: return the full text of the element that contains the text "valid" ?
Using: Watir 2.0.4 , Webdriver 0.4.1
Given the structure you provided, since divs are so often used I would be inclined to look for the table cell using a regular expression as Dave shows in his answer. Unless you have a lot of nested tables, it is more likely to return just the text you want.
Also if 'valid' may appear elsewhere then you might want to provide a slightly larger sample of the text to look for
. browser(:cell => /valid/).text
Try this
return browser.div(:text => /valid/).text
or
return browser.table.div(:text => /valid/).text
if the valid is not found, it should return nil.
I am currently working on a message watcher service we have and my task is to simply embed message details into the message body.
I have tried using a string builder for this however i have found that my message body is a html based string.
I'm wanting to know if there is a way i can add the values i want to add at a certain point in this html string?
Below is a section of the html string i want to manipulate. My text needs to be inserted directly after the body tag.
<body lang=EN-GB link=blue vlink=purple>
<div class=WordSection1>
<p class=MsoNormal>
<span style='font-size:10.0pt;font-family:"Century Gothic","sans-serif";color:black'>Another test for AppendLine();<o:p></o:p>
</span>
</p>
Here is how i was trying to do it:
StringBuilder sb = new StringBuilder();
sb.Append("From: ");
sb.Append(message.From.ToString());
sb.AppendLine();
sb.Append("Sent: ");
sb.Append(message.Date.ToString());
sb.AppendLine();
sb.Append("To: ");
sb.Append(message.To.ToString());
sb.AppendLine();
sb.Append("Subject: ");
sb.Append(message.Subject);
sb.AppendLine();
sb.Append(message.BodyHtml);
Unfortunately this just printed my From, Sent, To, Subject values onto one line and then output the html section.
If any more information is needed please let me know and i will provide it.
Instead of appending the body HTML, try this regex replace:
StringBuilder sb = new StringBuilder();
sb.Append("From: ");
sb.Append(message.From.ToString());
...
sb.Append("Subject: ");
sb.Append(message.Subject);
sb.AppendLine();
// not guaranteed to work with arbitrary HTML strings
Regex regex = new Regex(#"(<body[^>]*>)", RegexOptions.IgnoreCase);
message.BodyHtml = regex.Replace(message.BodyHtml, "$1\r\n" + sb.ToString());
Disclaimer: Please be advised that processing HTML with regular expressions is generally regarded as a bad idea. Although the code above might work in 98% of cases, regular expressions are not up to the task of parsing arbitrary HTML. HTML is too sophisticated for regex. If you need to process arbitrary HTML bodies (not just the one above), I strongly recommend using a proper HTML parser such as HTML Agility Pack - even for seemingly-simple operations such as inserting a text after the body tag.