Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. XML Import Failing on XMLDocument.Load: Unexpected end of file has occurred.

XML Import Failing on XMLDocument.Load: Unexpected end of file has occurred.

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpdatabasesql-serverxmltutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    D Dubya
    wrote on last edited by
    #1

    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 <b>xdoc.Load(xr)</b> 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 and thanks to validation on INSERT by MSSQL, we can assume(?) the document is well-formed. Does anyone know how to get 'large' amounts of XML from the database into my XmlDocument?

    Dim xr As XmlReader = ExportAdapter.GetEditedCheckXML(chkId)
    Dim xdoc As New XmlDocument
    xdoc.Load(xr)

    Here's the GetEditedCheck fn:

    Public Shared Function GetEditedCheckXML(ByVal checkId As Integer) As XmlReader
    
        Dim conn As SqlConnection = New SqlConnection(CONNECTION\_STRING)
        Dim comm As New SqlCommand("PS\_GetModifiedXmlByCheckId", conn)
        Dim adap As New SqlDataAdapter
    
        comm.CommandType = CommandType.StoredProcedure
        comm.Parameters.Add("@checkId", SqlDbType.Int).Value = CInt(checkId)
        conn.Open()
    
        Dim xml = comm.ExecuteXmlReader()
        xml.Read()
        conn.Close()
    
        Return xml
    End Function
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups