Author Topic: XML structure of LastErrorXml  (Read 633 times)

oleksii

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
XML structure of LastErrorXml
« on: November 08, 2017, 08:48:31 AM »
Hi,

Where can I get specification of the XML structure in LastErrorXml?

I need to parse it somehow to get user-friendly representation. For example, I got the following value after calling entry.Extract method:

<ChilkatLog>
  <Extract>
    <DllDate>Aug 30 2017</DllDate>
    <ChilkatVersion>9.5.0.69</ChilkatVersion>
    <UnlockPrefix>XXXXXXXXXXX</UnlockPrefix>
    <Architecture>Little Endian; 64-bit</Architecture>
    <Language>.NET 4.5 / x64</Language>
    <VerboseLogging>0</VerboseLogging>
    <inflateToBaseDir>
      <inflateMappedEntry>
        <inflateToOutput2>
          <mappedInflateToOutput>
            <error>Unsupported compression method.</error>
            <_cMethod>95</_cMethod>
          </mappedInflateToOutput>
        </inflateToOutput2>
        <error>Unzip failed</error>
        <path>C:\Users\user\AppData\Local\Temp\171\Extracted_archives\Zip_lmde0008.zipx\lmde0009.trc</path>
      </inflateMappedEntry>
    </inflateToBaseDir>
    <error>Failed.</error>
  </Extract>
</ChilkatLog>

What I want to get is only the following part: "Unsupported compression method.". To achieve this I need to know XML structure. As I understand structure depends on the operation that is failed. In this particular case XML contains Extract element.

Or maybe there is more simple way to get exact error, other than parsing XML.

Chilkat

  • Administrator
  • Full Member
  • *****
  • Posts: 103
  • Karma: +6/-0
    • View Profile
Re: XML structure of LastErrorXml
« Reply #1 on: November 08, 2017, 10:42:39 AM »
Thanks.  This question comes up quite a bit.  People want "an exact error".  The problem is that there are innumerable "exact errors" possible.  (Granted there are common errors that might occur.)

My belief is that when only an "exact error" is provided, it typically ends up being an arcane/cryptic message or some "error code".  You see this all the time with Microsoft errors -- where one gets some undecipherable, meaningless error message and code, which provides no context or even a glimpse of understanding was to what might be the cause of the problem.  The result is that the application developer wastes an enormous amount of time in working to solve each and every error.

Chilkat wants to provide context and details so that 95% of the time, the LastErrorText/LastErrorXml already has the information to understand the cause of the problem, and what is required to fix.  If the application developer remains uncertain, then he/she can pass it to Chilkat for advice, and that usually solves the problem quickly.

For common errors, one solution is to use the code generation for XML parsing at http://tools.chilkat.io/xmlParse.cshtml    You can copy-and-paste a sample of the LastErrorXml, such as what you posted, and then generate the code that parses it.  (You'll throw out most of it and only keep the parts you want..)   For example, the code generated, in C#, to generate the LastErrorXml you provided is: 

Code: [Select]
Chilkat.Xml xml = new Chilkat.Xml();

//  Insert code here to load the above XML into the xml object.

string tagPath;
string DllDate;
string ChilkatVersion;
string UnlockPrefix;
string Architecture;
string Language;
int VerboseLogging;
string error;
int v_cMethod;
string path;

DllDate = xml.GetChildContent("Extract|DllDate");
ChilkatVersion = xml.GetChildContent("Extract|ChilkatVersion");
UnlockPrefix = xml.GetChildContent("Extract|UnlockPrefix");
Architecture = xml.GetChildContent("Extract|Architecture");
Language = xml.GetChildContent("Extract|Language");
VerboseLogging = xml.GetChildIntValue("Extract|VerboseLogging");
error = xml.GetChildContent("Extract|inflateToBaseDir|inflateMappedEntry|inflateToOutput2|mappedInflateToOutput|error");
v_cMethod = xml.GetChildIntValue("Extract|inflateToBaseDir|inflateMappedEntry|inflateToOutput2|mappedInflateToOutput|_cMethod");
error = xml.GetChildContent("Extract|inflateToBaseDir|inflateMappedEntry|error");
path = xml.GetChildContent("Extract|inflateToBaseDir|inflateMappedEntry|path");
error = xml.GetChildContent("Extract|error");