I have written Apps Script code for Html Parsing using XmlParse. It works fine at my end, my browser and system language both are English as well as my Google Account's. But when I shared the same script with Client in Italy, it gives error
The markup in the document following the root element must be well-formed!
I am confused if its the same HTML code then why is it giving error at client's end.
I am wondering if ther is any regional or language settings required to be updated for this?
I already tried changing locale of the associated Google Sheet.
Following is the HTML Structure
<div dir=""ltr"">
<div dir=""ltr"">
<div align=""center"">
<div style=""font:20pt Times New Roman""><b>TITLE</b></div>
<br></br>
<table cellspacing=""1"" cellpadding=""3"" border=""0"">
<tbody>
<tr align=""left"">
<td colspan=""2""><b>Account: </b></td>
<td colspan=""5""><b>Name: a</b></td>
<td colspan=""2""><b>Currency: USD</b></td>
<td colspan=""2""><b>Leverage: </b></td>
<td colspan=""3"" align=""right""><b>2024 June 22, 09:14</b></td>
</tr>
<tr align=""left""><td colspan=""13""><b>Closed Transactions:</b></td></tr>
<tr align=""center"" bgcolor=""#C0C0C0"">
<td>Ticket</td>
<td>Open Time</td>
<td>Type</td>
<td>Size</td>
<td>Item</td>
<td>Price</td>
<td>S / L</td>
<td>T / P</td>
<td>Close Time</td>
<td>Price</td>
<td>Commission</td>
<td>Taxes</td>
<td>Swap</td>
<td>Profit</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Below is my appscript function
function sanitizeHtml(htmlContent) {
return htmlContent.replace(/<meta([^>]*?)\/?>/g, '<meta$1></meta>')
.replace(/<img([^>]*?)\/?>/g, '<img$1></img>')
.replace(/<br([^>]*?)\/?>/g, '<br$1></br>')
.replace(/<hr([^>]*?)\/?>/g, '<hr$1></hr>')
.replace(/ /g, ' ')
.replace(/\s+nowrap/gi, '')
.replace(/\\(\#|0|,|\.|\\)/g, '$1');
}
function extractDateFromHtml(htmlContent) {
// Parse the HTML content
var sanitizedHtml = sanitizeHtml(htmlContent);
var doc = XmlService.parse(sanitizedHtml);
}
