XML support
Question asked by Arthur Gorr - March 23 at 6:24 AM
Answered
We are seeing this error when attempting to view an XML file: 
    The file is corrupted or is not a spreadsheetML file.
 
The XML content is valid:
<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>
 
The supported documents page refers to "Microsoft Excel 2003 XML Spreadsheet".  Is that some specific XML schema?  Can DocumentUltimate support viewing of arbitrary XML content?

3 Replies

Reply to Thread
0
Cem Alacayir Replied
Employee Post
Yes, XML is one of the formats Excel generates so when you pass a file with .xml extension, it thinks it's an Excel generated file and tries to load it as that.
 
For regular XML files, you can specify the format explicitly as DocumentFormat.Txt and this way DocumentUltimate can interpret it as a text file. However as of current version you can only specify format when you use DocumentViewer.DocumentSource or DocumentViewer.DocumentHandlerType properties. Maybe we should add a new property DocumentViewer.DocumentFormat so that it can be used along with DocumentViewer.Document.
 
By the way, why do you need to use DocumentViewer for viewing XML files? As far as I know browsers can already display XML files with syntax highlighting which seems a better fit.
1
Cem Alacayir Replied
Employee Post
FYI, we have released 3.15.5:
 
  • Added: New property DocumentViewer.DocumentFormat. By default, the format is determined from the file extension but you can use this property when you don't have an extension or when you need to override the format determined from the extension. Refer to DocumentViewer.DocumentFormat property in the updated docs for more details.

So now you will have the ability to override the document format like this:
 
documentViewer.Document = @"c:\SomeFolder\Document.xml";
//Force "Document.xml" to be treated as DocumentFormat.Txt
documentViewer.DocumentFormat = DocumentFormat.Txt;
 
However, there still seems to be a problem specific to converting XML files (it's a text file but the tags in it currently confuse the converter so the generated PDF has no pages). I just wanted to let you know about the new property (at least you can use it for other formats that you want to treat specially) and we will fix the XML specific issue in the next version.
0
Cem Alacayir Replied
Employee Post
FYI, we have released v3.16.0:
 
Changed: Removed DocumentFormat.Xml (SpreadsheetML - Excel 2003 XML Spreadsheet) as .xml extension is widely used for text files. So now by default .xml files will be treated as plain text files and DocumentViewer will be able to display them.
 
So now you can view .xml files directly (no need to even set documentViewer.DocumentFormat property)

Reply to Thread