How I can 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 starts on the xmlDoc.Active code.
<?xml version="1.0" encoding="UTF-8" ?>
- <WORDSET>
- <WORD NUMBER="1">
<ENGLISH>beat</ENGLISH>
<KOREAN>두드리다</KOREAN>
</WORD>
Project.exe raised exception class EDOMParseError with message ‘An invalid character was found in text content.
But when I remove the Korean characters from the XML, then the code is okay.
I see you use Indy’s http component. When you get an URL you have to provide a stream (which you probably do in your GetHTTP method). When that stream contains the xml and nothing else, use the stream directly with the
LoadFromStreammethod of yourTXMLDocument. TXMLDocument will determine the encoding so it saves you from fooling around with strings and encodings.Ofcourse, for al this to work contentlesson.php has to return proper XML (as commented by Robert Love). If that part you posted is exactly what you got from that page, then it is not your fault when you get errors.