Note that there are some explanatory texts on larger screens.

plurals
  1. POError on taking strings from an excel file to .xml file
    primarykey
    data
    text
    <p>I am taking some strings from a .xlsx file (the strings are simple characters). Then I am trying to put those strings in an .xml file. But unfortunately, when I put those strings in the ‘createElement(StringVariableHere)’ method, I get the following error: "org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified."</p> <p>I get the string values in this way:</p> <pre><code>switch (tempCell.getCellType()) { case Cell.CELL_TYPE_STRING: String tempColValue = tempCell.getStringCellValue(); } </code></pre> <p>And this is the line where i try to add my string values and it gives me the error.</p> <pre><code>Element titleChild = doc.createElement(StringVariableHere); </code></pre> <p>I even tried to clean the string using the following method i found online:</p> <pre><code>public String stripNonValidXMLCharacters(String in) { StringBuffer out = new StringBuffer(); // Used to hold the output. char current; // Used to reference the current character. if (in == null || ("".equals(in))) return ""; // vacancy test. for (int i = 0; i &lt; in.length(); i++) { current = in.charAt(i); // NOTE: No IndexOutOfBoundsException caught here; it should not happen. if ((current == 0x9) || (current == 0xA) || (current == 0xD) || ((current &gt;= 0x20) &amp;&amp; (current &lt;= 0xD7FF)) || ((current &gt;= 0xE000) &amp;&amp; (current &lt;= 0xFFFD)) || ((current &gt;= 0x10000) &amp;&amp; (current &lt;= 0x10FFFF))) out.append(current); } return out.toString(); } </code></pre> <p>Also i am using the following to check if it is valid or not, and when i add my string it returns false:</p> <pre><code>XMLChar.isValidName(StringVariableHere) </code></pre> <p>Thank you all so much for your time. Stefanos.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload