sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
cody's Avatar

Trying to parse OpenDocument files (sxw)


Question posted by: cody (Guest) on August 11th, 2008 08:25 PM
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);
}
}
1 Answer Posted
cody's Avatar
Guest - n/a Posts
#2: Re: Trying to parse OpenDocument files (sxw)

cody wrote:
Quote:
Originally Posted by
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 :)
 
Not the answer you were looking for? Post your question . . .
197,039 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,039 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors