Re: Getting exception: Cannot have '?>' inside an XML processing

From: Mike Lansdaal (mlans80_at_newgroup.nospam)
Date: 09/02/04


Date: Thu, 2 Sep 2004 16:55:08 -0700

Kevin - Yes, your understanding is correct.

The document starts as an SGML document authored in Arbortext's Adept
editting tool, and then an XML version is provided to me via their E3
engine. I obtain the document using the WebClient class to get a byte array
and then use the UTF8Encoding class to convert into a string. That string
data is then dumped to a file use the StreamWriter class. My temporary
workaround is to process the string data first (load into a StringBuilder
object and add line breaks between tag end and start characters) before
dumping it into the file . File downloading typically occurs when the
application starts up. At some later time, the user of my application will
select that file to be processed. We create a XmlDocument object (_xmlTest)
and load it from the selected file path (_xmlTestFile) in the statement
"_xmlTest.Load( _xmlTestFile );". When iterating through the document nodes
we see the problem if we access the node's innerXMl property (or even just
try to write the document out).

Interestingly, if we access the innerText property there is no exception,
however the number of child nodes is smaller (2 nodes are "lost").
Originally we suspected a problem with the authoring tool or the E3 engine
as our end user had editted a file in the authoring tool and then our
application failed to parse it. Further investigation showed that the
parsing is quite sensitive to the data content in these files, and
that the structure of the files produced by the tools was not an issue. The
size of the downloaded test files range from around 100KB to 246KB.
Unfortunately, the file content is proprietary, so if you need the actual
file, I will have to find a way to substitute the innerText data with random
text of the same length.

We are running .NET Framework 1.1 on Windows 2000 SP4. We had been running
under SP2 and SP3 previously and have recently upgraded to SP4 to be able to
run a new device driver. It occurred to me that maybe this could be the
source of the problem, but today I ran different versions of the application
under SP2, and SP4 and the error is not localized to a particular version. I
have also run it under Windows XP SP1 and have the same error.

Thanks, Mike

"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:aiTbEwLkEHA.1968@cpmsftngxa10.phx.gbl...
> Hi,
>
> First of all, I would like to confirm my understanding of your issue. From
> your description, I understand that when you're trying to parse an xml
> document using XmlDocument. If there is any misunderstanding, please feel
> free to let me know.
>
> From the exception message, it seems that there is something wrong with
the
> instruction between <? ?>. But from the xml fragment you have provided,
> there seems to be nothing wrong. I suspect that there might be some
> encoding issues, since when you open and save it in XMLSpy, it works well.
> Could you let me know, from where you got this xml document?
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



Relevant Pages