Link to home
Start Free TrialLog in
Avatar of psmithphil
psmithphilFlag for United States of America

asked on

XML will not show in the browser.

I'm using vb.net in an asp.net application built in Visual Studio 2005 on WindowsXP.
I am trying to get an xml file to output to the browser.  My program brings in the xml file from a url, then goes through the code (below) to rebuild the xml.  The reason I run it through this code is so the url in the browser address bar will not show where the file is located.  
After the code rebuilds the file, it sends it out to the browser.  I get the error "The XML page cannot be displayed.  The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document".

When I look at "View Source" (below) it shows the xml exactly like it should be.  But I can't get the file to display in the browser.  I'm close, but I need that last step in getting it to the browser.  Can you see where I'm missing it?
'CODE:
 Response.ClearContent()
                Response.ClearHeaders()
                Response.ContentType = "application/xml"
                TypeOfOutputFile = "Output File coming From URL"
               Const STREAM_SIZE = 1048576 'Approx. 1MB. Old value was 8192 which equals 8K.  8192 does not help file damaged issue.
                ' Create a temporary buffer to read from response and write to PDF stream
                Dim Buffer() As Byte = New Byte(STREAM_SIZE) {}
                ' Read the first chunk
                Dim Count As Long = 0
                Dim i As Long = 0
                Dim iSize As Long = STREAM_SIZE
                Count = strmResponseStream.Read(Buffer, i, Buffer.Length)
                ' Read the PDF file till end of stream is reached.
                While Count > 0 'and i >= buffer.Length 
                    i = i + Count
                    ''Count = strmResponseStream.Read( Buffer, 0, Buffer.Length)
                    If i > iSize - STREAM_SIZE Then
                        iSize = iSize + STREAM_SIZE
                        ReDim Preserve Buffer(iSize)  'increases the buffer size.
                    End If
                    Count = strmResponseStream.Read(Buffer, i, Buffer.Length - i)
                End While
                strmResponseStream.Close()
                ReDim Preserve Buffer(i - 1)
Response.BinaryWrite(Buffer) 
Response.Flush()
Response.End()
 
 
VIEW SOURCE:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="/models/company%20document%20routing/sigsheet.xsl"?>
<sigsheet>
	<DocumentNumber>CP-058563</DocumentNumber>
	<DocumentRevision>N/C</DocumentRevision>
	<DocumentDisplayFile>CP-058563.PDF</DocumentDisplayFile>
	<DocumentType>BUILDING PLANS</DocumentType>
	<DocumentTitle>CP-058563</DocumentTitle>
 
	<DocumentOriginator>Tim Allen</DocumentOriginator>
	<DocumentOriginatorTitle>Analyst</DocumentOriginatorTitle>
	<Signatories>
		<signature>
			<name>Tim Allen</name>
			<login>Adudks</login>
			<title>Analyst</title>
 
			<timestamp>4/12/2006 11:21:48 AM</timestamp>
			<assigned>4/12/2006 11:11:15 AM</assigned>
		</signature>
	</Signatories>
</sigsheet>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Craig Wagner
Craig Wagner
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of psmithphil

ASKER

You were right, Craig!   I was going through it on the server in debug mode (as localhost) and it didn't know where the stylesheet was.  When I went to the server using http://server.company.com, it was able to find the stylesheet.  So my code was okay, I just wasn't referencing the server correctly.  Thank you!