PublicError

Hi

I download a XML-file via HTTP (HttpWebRequest) to a MemoryStream.

The XML-file starts with:

< xml version="1.0" encoding="ISO-8859-1" >

<!DOCTYPE sports SYSTEM "sports.dtd">

Now I want to create a XmlDocument using the MemoryStream.

I have:

XmlDocument xml = new XmlDocument();

xml.Load(memoryStream);

The problem is that I get a "Root element is missing" error at "xml.Load".

I guess that's because the "sports.dtd" file is not applied.

(If I save to file first, and then load "sports.xml", I get no errors. This because "sports.dtd" is correctly loaded).

So my question is:

How do I tell the XmlDocument to use "sports.dtd" when loading the memory stream

Thanks in advance.



Re: XML and the .NET Framework Load XmlDocument from MemoryStream - DTD problem

Martin Honnen

Can you show us your code To me the error message sounds rather as if you do not set

memoryStream.Position = 0

before you pass the memory stream to the Load method.

Why do you need to memory stream at all The Load method can take a HTTP URL without problems.






Re: XML and the .NET Framework Load XmlDocument from MemoryStream - DTD problem

PublicError

Hi Martin

Position=0 did it Smile

I didn't now the load method could take a HTTP URL as well.

Thanks!