@abrakadaber: to mi nic nie daje, jakies zawiłe te podpowiedzi.
Tak czy inaczej, użyłem do odczytu TSrringList, chociaz wiem ze to nie jest profesionalne podejscie.
Tak na szybko
unit main;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
{
XML
<?xml version="1.0" encoding="UTF-8" ?>
<save>
<header version="2" time="1534250670" />
<version major="3" minor="6" revision="0" build="3" />
<region id="Config">
<node id="root">
<children>
<node id="ConfigEntry">
<attribute id="MapKey" value="Language" type="22" />
<attribute id="Type" value="1" type="5" />
<attribute id="Value" value="Polish" type="20" />
</node>
</children>
</node>
</region>
</save>
}
const
LangLine = '<attribute id="Value" value="Polish" type="20" />';
XMLFILE = 'test.xml';
type
TMainForm = class(TForm)
private
{ Private declarations }
function AddSplash(const s: string): string;
function GetLanguageXML(const FileName: string = XMLFILE): string;
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
// dodaj na koncu \
function TMainForm.AddSplash(const s: string): string;
begin
if s[Length(s)] <> '\'
then
Result := s + '\'
else
Result := s;
end;
function TMainForm.GetLanguageXML(const FileName: string): string;
var
XML: TStringList;
s: string;
i, x, y: Integer;
begin
Result := '';
XML := TStringList.Create();
try
XML.LoadFromFile(AddSplash(ExtractFilePath(Application.ExeName)) + FileName);
/// szukanie indexu z lina do edycji jezyka
for i := XML.Count - 1 downto 0 do begin
if TrimLeft(XML[i]) = LangLine then begin
s := XML[i];
Break;
end;
end;
// obecny jezyk w <attribute id="Value" value=TU JEST JEZYK
x := System.SysUtils.AnsiPos('value', s) + Length('value') + 2;
y := System.SysUtils.AnsiPos('type', s) - 2;
Result := Copy(s, x, y-x);
finally
XML.Free();
end;
end;
end.