EDOM Parse error (invalid character found in text) / Korean characters Problem

How can i fix this?

  Tdm = class(TDataModule)
  HTTP: TIdHTTP;
  XMLDoc: TXMLDocument;
  ...
  var sStory: String;
  ...
  sStory:= GetHTTP('http://localhost/MultiPlay_PHP/contentlesson.php');
  begin
  xmlDoc.XML.Text := sStory;
  xmlDoc.Active :=true;

  StartItemNode := XMLDoc.DocumentElement.ChildNodes.First;
  ANode := StartItemNode;

The error begins with the code xmlDoc.Active.

<?xml version="1.0" encoding="UTF-8" ?> 
- <WORDSET>
- <WORD NUMBER="1">
  <ENGLISH>beat</ENGLISH> 
  <KOREAN>두드리다</KOREAN> 
  </WORD>

Project.exe raised an EDOMParseError exception class with the message "An invalid character was found in text content. But when I remove Korean characters from XML, then the code is fine.

+3
source share
2 answers

, http Indy. URL-, ( , , GetHTTP). xml , LoadFromStream TXMLDocument. TXMLDocument , .

, , contentlesson.php, XML ( ). , , , , , .

+1

, - UTF-8. , sStory: String sStory : UTF8string

, .

var
 sStory : Utf8String;
begin
 sStory := '<?xml version="1.0" encoding="UTF-8" ?>' +
           '<WORDSET>'  +
           '<WORD NUMBER="1">'  +
           '<ENGLISH>beat</ENGLISH>'  +
           '<KOREAN>두드리다</KOREAN>'  +
           '</WORD>'  +
           '</WORDSET>';
 xmlDoc.XML.Text := sStory;
 xmlDoc.Active := true;
end;
+1

Source: https://habr.com/ru/post/1751336/


All Articles