473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XmlDocument.Load: Unexpected end of file has occurred.

Hi all,

I'm attempting to load an xml document from an XML column in MSSQL 2008, into an XmlDocument (see code below).

Sometimes the code will break at the xdoc.Load(xr) line with the error "Unexpected end of file and occurred". After breaking, the XmlReader has a value of "None".

While researching the problem, I saw posts that referred to a 4Kb limit on StreamReaders and figured this may be related somehow. So I cut down the size of my document (to around 4Kb) and everything worked fine.

On average, the XML documents I'm importing from the database are 20Kb.

Does anyone know how to get a 'large' amounts of XML from the database into my XmlDocument?

Expand|Select|Wrap|Line Numbers
  1. Dim xr As XmlReader = ExportAdapter.GetEditedCheckXML(chkId)
  2. Dim xdoc As New XmlDocument
  3. xdoc.Load(xr)
  4.  
Here's the GetEditedCheck fn:
Expand|Select|Wrap|Line Numbers
  1.     Public Shared Function GetEditedCheckXML(ByVal checkId As Integer) As XmlReader
  2.  
  3.         Dim conn As SqlConnection = New SqlConnection(CONNECTION_STRING)
  4.         Dim comm As New SqlCommand("PS_GetModifiedXmlByCheckId", conn)
  5.         Dim adap As New SqlDataAdapter
  6.  
  7.         comm.CommandType = CommandType.StoredProcedure
  8.         comm.Parameters.Add("@checkId", SqlDbType.Int).Value = CInt(checkId)
  9.         conn.Open()
  10.  
  11.         Dim xml = comm.ExecuteXmlReader()
  12.         xml.Read()
  13.         conn.Close()
  14.  
  15.         Return xml
  16.     End Function
  17.  
Jun 21 '10 #1
1 3719
I was able to get around this problem by returning a String instead of an XmlReader object from my adapter function. I then used xdoc.LoadXml() to load the string.
Aug 5 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gustaf Liljegren | last post by:
I need to merge several XML files into one large. All of them has a DOCTYPE tag, but the SYSTEM identifier points to a DTD that doesn't exist. (I use the PUBLIC identifier with catalog files, so...
1
by: Dave | last post by:
Can you load an XmlDocument with a file located on a network share? I thought maybe the XmlResolver could be used XmlUrlResolver resolver = new XmlUrlResolver() resolver.Credentials =...
1
by: Chief | last post by:
I am unable to load an xml document that contains Chinese characters in an attribute value. I need to load the document into and XmlDocument object and am using the XmlDocument.Load(string...
3
by: Dave Brown | last post by:
Hi All, Is it possible to examine the progress of a XMLDocument.Load method ? Sometimes my documents might be quite large so I want to give the user some indication of the size and progress. ...
3
by: ek03 | last post by:
I have a web application that saves/loads XML documents. On occasion, an error is logged on the call to XmlDocument.Load: "process cannot access the file <filepath here> because it is being used by...
3
by: Atara | last post by:
I use the following code to load xml file: Dim srcXml As String = pathDataFiles & "test.xml" Dim XmlDoc As New Xml.XmlDocument XmlDoc.Load(srcXml) If my xml file starts with the line - ...
2
by: supercodepoet | last post by:
I have cXml document I want to load to parse. The document has a DOCTYPE element that points to an external dtd via http. When the document loads it trys a web request which I am assuming is to...
10
by: lamxing | last post by:
Dear all, I've spent a long time to try to get the xmldocument.load method to handle UTF-8 characters, but no luck. Every time it loads a document contains european characters (such as the...
4
by: DanThMan | last post by:
The following code works when I debug and when I install the software and run the .exe, but if I try to open the form in the designer (which causes this code to run), I get an error: Private Sub...
1
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
The description of the XMLDocument.Load method doesn't quite answer the question. When passing in a FileStream object to the Load method, does it load the entire document into memory? For...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.