Sign In  Sign Up Live-Chat

Root element is missing

Last post 05-07-2008, 6:42 PM by lukeyoyo. 2 replies.
Sort Posts: Previous Next
  •  05-07-2008, 3:05 PM 125886

    Root element is missing

    I keep getting this particular error when using the ImportXml method with a memory stream, the example uses a filestream, is there something additional I must do for a memory stream?

    In memory it looks correct as follows:

    <form1>
       <txtName>Test</txtName>
    </form1>

    I'm using the System.Xml.XmlDocument class to build an xml document in memory to pass along to a library that fills out a PDF.  A file would be a simple solution but it would be nice to have this working without the go between.
     
  •  05-07-2008, 3:13 PM 125889 in reply to 125886

    Re: Root element is missing

    Nevermind, I found the solution.  When using a memory stream you have to be sure to reset the position property for the memory stream otherwise the function thinks the stream has a 0 byte length.  The fix is to simply set the position to 0.  Something like this:

    Dim memoryStream As System.IO.Stream = New System.IO.MemoryStream()
    objXmlDocument.Save(memoryStream)
    memoryStream.Position = 0
     
  •  05-07-2008, 6:42 PM 125901 in reply to 125886

    Re: Root element is missing

    Dear BCS,

    Thanks for considering Aspose.Pdf.Kit and for sharing your experience.

    You are quite right. A positioning operation is needed for memory stream. And please feel free if you have any other question.

    Best regards.


    Luke Fu
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
View as RSS news feed in XML