473,699 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Root element is missing" xml stream problem

I am getting a "Root element is missing" error when I try to load a
stream into and
XmlDocument. Can anyone help me with what I am doing wrong???
Dim xmlTextWriter As XmlTextWriter = Nothing
Dim objFile As FileStream = Nothing

objStream = New MemoryStream()

xmlTextWriter = New System.Xml.XmlT extWriter(objSt ream, _
Encoding.GetEnc oding("iso8859-1"))

xmlTextWriter.F ormatting = System.Xml.Form atting.Indented
xmlTextWriter.W riteStartDocume nt(True)
xmlTextWriter.W riteComment("Th is file represents " & _
"data for source system.")
xmlTextWriter.W riteStartElemen t("requests", Nothing)
xmlTextWriter.W riteEndElement( ) 'End of Requests element
xmlTextWriter.F lush()

objStream = xmlTextWriter.B aseStream()
Dim objXMLDoc As XmlDocument = New XmlDocument
objXMLDoc.Load( objStream)

Mar 9 '07 #1
3 35065
add a "WriteEndDocume nt() like below.

hth,

Rick
<li*********@ed s.comwrote in message
news:11******** **************@ h3g2000cwc.goog legroups.com...
>I am getting a "Root element is missing" error when I try to load a
stream into and
XmlDocument. Can anyone help me with what I am doing wrong???
Dim xmlTextWriter As XmlTextWriter = Nothing
Dim objFile As FileStream = Nothing

objStream = New MemoryStream()

xmlTextWriter = New System.Xml.XmlT extWriter(objSt ream, _
Encoding.GetEnc oding("iso8859-1"))

xmlTextWriter.F ormatting = System.Xml.Form atting.Indented
xmlTextWriter.W riteStartDocume nt(True)
xmlTextWriter.W riteComment("Th is file represents " & _
"data for source system.")
xmlTextWriter.W riteStartElemen t("requests", Nothing)
xmlTextWriter.W riteEndElement( ) 'End of Requests element
*************** *******
xmlTextWriter.W riteEndDocument ()

*************** *********
xmlTextWriter.F lush()

objStream = xmlTextWriter.B aseStream()
Dim objXMLDoc As XmlDocument = New XmlDocument
objXMLDoc.Load( objStream)

Mar 9 '07 #2
li*********@eds .com wrote:
I am getting a "Root element is missing" error when I try to load a
stream into and
XmlDocument. Can anyone help me with what I am doing wrong???
objStream = xmlTextWriter.B aseStream()
Dim objXMLDoc As XmlDocument = New XmlDocument
objXMLDoc.Load( objStream)
Set
objStream.Posit ion = 0
before the Load call.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 9 '07 #3
On Mar 9, 7:50 am, Martin Honnen <mahotr...@yaho o.dewrote:
lisa.bog...@eds .com wrote:
I am getting a "Rootelementism issing" error when I try to load a
streaminto and
XmlDocument. Can anyone help me with what I am doing wrong???
objStream = xmlTextWriter.B aseStream()
Dim objXMLDoc As XmlDocument = New XmlDocument
objXMLDoc.Load( objStream)

Set
objStream.Posit ion = 0
before the Load call.

--

Martin Honnen --- MVPXML
http://JavaScript.FAQTs.com/
Thanks - this fixed it!

Mar 9 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3758
by: Jonathan | last post by:
Hi all: I originally posted this in an HTML forum, but have realized that the solution may (a) require a server-side change or (b) be non-existent. In any case, since the page I'm dealing with is a PHP page and the problem has to do with an auto-inserted "input" element, I'll post it here, too. I'd appreciate any advice, commentary, or even pessimistic sympathy if I'm just SOL. - Thanks. I am pasting some code below that I am having a...
0
2026
by: damontimm | last post by:
My setup: Mac OS 10.4.4; mysql 4.x ... everything was installed and working fine for some time. Today, I added drupal to my system and had to create a new database in mysql -- now I am having some problems. I will outline the problem, what I have tried to do to fix it, and what I think caused it. Hope you can help and I am sorry this is long. The problem: I can't login to mysql anymore with the "root" username (which is where I have all...
1
4741
by: tankbattle | last post by:
That is, what's the difference between <complexType name="Address" final="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element name="city" type="string"/> </sequence> </complexType> and <complexType name="Address" block="restriction">
1
5755
by: Tomas | last post by:
When I try to load my xslt i get an xml exception with the message "Root element is missing". The stylesheet works when I preview it in stylus studio, but apparently not in my application. Any ideas what may be wrong? The stylesheet: <?xml version="1.0" encoding="utf-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output indent="yes"/>
2
8362
by: tony | last post by:
XslCompiledTransform xslt = new XslCompiledTransform(); ASCIIEncoding encodeToByteArray = new ASCIIEncoding(); MemoryStream inputStream = new MemoryStream(); MemoryStream outputStream = new MemoryStream(); MemoryStream xslStream = new MemoryStream(); String inputString = "<foo>Hello XSL</foo>"; byte inputArray = encodeToByteArray.GetBytes(inputString);
6
78394
by: active | last post by:
This works with Strict Off But not with Strict On Sometimes I can figure out what is needed by running it and using QuickWatch to see the type required but GetObject("winmgmts:\\" & StrComputer & "\root\cimv2") returns a value System._ComObject of Type Object
11
3887
by: MC | last post by:
I have a couple of customers who are using a program that deserializes an XML file, and on some files, the program fails to see the content of the file -- treats it as zero length and reports "root element is missing" -- even though in Notepad the file looks normal. Has anybody ever seen this? Any clues? I have not been able to reproduce it on my computer. In general, when they e-mail me the files, the files arrive perfectly normal. ...
2
10991
by: Tom Chang | last post by:
Try to read following type of XML file, but only get data back on first node: <log id="1234"> <message type="Action"/> </log> <log id="5678"> <message type="Drama"/> </log> <log id="1357">
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9033
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7748
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.