Connecting Tech Pros Worldwide Help | Site Map

Trying to parse OpenDocument files (sxw)

  #1  
Old August 11th, 2008, 08:25 PM
cody
Guest
 
Posts: n/a
Iam trying to read in sxw files and generate a preview for it.
The problem now is that the file "content.xml" seem to contain a DTD.
I do not want to process this DTD because this is a separate file which
is not available at this time.

I tried everything, but no matter what I do I get errors that the DTD is
not found or cannot be accessed due to security reasons.

Can't I deactivate usage of the DTD?

XmlReaderSettings s = new XmlReaderSettings();
s.IgnoreComments = true;
s.IgnoreWhitespace = true;
s.IgnoreProcessingInstructions = true;
s.ValidationType = ValidationType.None;
s.ProhibitDtd = true;
s.ValidationFlags = XmlSchemaValidationFlags.None;

using (XmlReader reader = XmlReader.Create(stream, s))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Text)
text.Append(reader.Value);
}
}
  #2  
Old August 11th, 2008, 08:25 PM
cody
Guest
 
Posts: n/a

re: Trying to parse OpenDocument files (sxw)


cody wrote:
Quote:
Iam trying to read in sxw files and generate a preview for it.
The problem now is that the file "content.xml" seem to contain a DTD.
I do not want to process this DTD because this is a separate file which
is not available at this time.
>
I tried everything, but no matter what I do I get errors that the DTD is
not found or cannot be accessed due to security reasons.
>
Can't I deactivate usage of the DTD?
>
XmlReaderSettings s = new XmlReaderSettings();
s.IgnoreComments = true;
s.IgnoreWhitespace = true;
s.IgnoreProcessingInstructions = true;
s.ValidationType = ValidationType.None;
s.ProhibitDtd = true;
s.ValidationFlags = XmlSchemaValidationFlags.None;
>
using (XmlReader reader = XmlReader.Create(stream, s))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Text)
text.Append(reader.Value);
}
}
Sorry for bothering you, it now works. I just had to set XmlResolver to
null :)
Closed Thread