שתף באמצעות


Xml Convert to String in VB.Net

Question

Monday, March 15, 2010 5:07 PM

     

    Dim fs As FileStream = File.Open(fileUpload1.PostedFile.FileName, FileMode.Open, FileAccess.Read)
                Dim buffer(fs.Length) As Byte
                fs.Read(buffer, 0, fs.Length - 1)
                txtRawXML.Text = System.Text.ASCIIEncoding.ASCII.GetString(buffer)

when I tried to upload file i got error 

The error description is 'A name contained an invalid character.'. Could not find prepared statement with handle 0. Could not find prepared statement with handle 0. sp_xml_removedocument: The value supplied for parameter number 1 is invalid. The statement has been terminated.

Trying to convert XML file to string and pass to  store procedure.

Thanks,



Tej http://tejzatms.blogspot.com/

All replies (3)

Monday, March 15, 2010 5:28 PM ✅Answered

        Dim xmldoc As New System.Xml.XmlDocument
        xmldoc.Load(fileUpload1.PostedFile.FileName)
        Dim allText As String = xmldoc.InnerText

Thanks

29 days to go !
My BlogMy Facebook


Monday, March 15, 2010 5:50 PM

Thanks, 

I used as 

                Dim reader = _
                        System.Xml.XmlReader.Create(fileUpload1.PostedFile.FileName)
                reader.MoveToContent()
                Dim inputXml = XDocument.ReadFrom(reader)
                txtRawXML.Text = inputXml.ToString

Is there any drow back with using Xml Reader or XmlDocument ?

Thanks,


Monday, March 15, 2010 6:37 PM

not really, actually xml reader should be faster than xml document..Thanks

29 days to go !
My BlogMy Facebook