<?xml version="1.0" encoding="windows-1252"?>
XmlDocument1.LoadFromFile('test.xml'); if XmlDocument1.Encoding <> 'windows-1252' then begin XmlDocument1.Encoding := 'windows-1252'; //Remplacement du caractère unicode de l'Euro XmlDocument1.XML.Text := StringReplace(XmlDocument1.Xml.Text, '€', '€', [rfReplaceAll, rfIgnoreCase]); end; XMLDocument1.Active := True; XmlDocument1.SaveToFile('Test.xml');
var BadEncoding: boolean; sl: TStringList; const Fichier = 'test.xml'; begin sl := TStringList.Create; try sl.LoadFromFile(Fichier); //supprimer les espaces ajoutés pour publier sur DelphiFr sl.Text := StringReplace(sl.Text, '& e u r o ;', '& # 1 2 8;', [rfReplaceAll, rfIgnoreCase]); sl.SaveToFile(Fichier); finally sl.Free; end; XmlDocument1.LoadFromFile(Fichier); BadEncoding := XmlDocument1.Encoding <> 'windows-1252'; if BadEncoding then begin XmlDocument1.Encoding := 'windows-1252'; //Remplacement du caractère unicode de l'Euro //supprimer les espaces ici aussi (voir plus haut) XmlDocument1.XML.Text := StringReplace(XmlDocument1.Xml.Text, '& # 1 2 8 ;', '€', [rfReplaceAll, rfIgnoreCase]); end; XMLDocument1.Active := True; if BadEncoding then XmlDocument1.SaveToFile(Fichier);