1
XML support
Question asked by Arthur Gorr - 3/23/2018 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?

4 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.
0
Arthur Gorr Replied
Thank you for the response. We are using the DocumentViewer to present a "secure preview" that prevents copy to clipboard (select text), download, print, etc. For multiple file formats, including XML. Ideally all formats can be presented using a common display tool such as DocumentUltimate viewer. Apart from the XML "limitation" the tool has met our requirements very well and the early feedback from customers is excellent.
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 Marked As Answer
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