vXML.Active := True => EDOMParseError at “%25” char sequence

375 views Asked by At

I have this problem in Delphi when I want to load an XML file that contains a "%25" in it's file name..

   vXML := TXMLDocument.Create(nil);
  vXML.FileName := pFileName;
  try
    try
      vXML.Active := True;

In debug mode there's an error in line

vXML.Active := True; 

Error:

First chance exception at $75ACC41F. Exception class EDOMParseError with message

Line: 0 '.

Enyone knows how to make TXMLDocument open a file with the "%25" chars in it's file name?

The file is not empty - I checked it. When I delete the "%25" chars everything is working fine. Sample file name: "something %25.xml"

My system and IDE: Windows 7 Home Premium with service pack 1; Delphi 2010;

1

There are 1 answers

2
Jacek Rz. On

To correctly load a file with (for example) "%25" in it's file name, we must use PathEncode on the file path. For example:

uses idURI;

[...]

vXML.LoadFromFile(TIdURI.PathEncode(pFileName));

WARNING: If you use chars that are e.g. 'ó' THIS WON'T WORK...