473,243 Members | 1,750 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,243 software developers and data experts.

ERR: The root element is missing

I'm in a real pickle. I've inherited a project with major problems. It
receives encrypted XML files from a website not under my control (so I can't
modify the web app) for insertion into a database. I'm under intense
pressure to get the data into the database NOW. I can decrypt the files
alright and they look like xml, they'll import into Access 2K3 with no
problem, but VB.Net will not read them. It's complaining about no root
element, and it's right there is no root element. I've tried manually
adding a root to the decrypted file but the remainder winds up unreadable.

Here is the top few lines of the decrypted file.
<dsFullStudentDataNew xmlns="NetFrameWork">
<student_table>
<ssn>000000000</ssn>
<first_name>rushmi</first_name>
<middle_initial>p</middle_initial>
<last_name>john</last_name>
<dob>11/12/1978</dob>
<gender>Female</gender>
<present_address>16 kavanaugh</present_address>

The code I'm using to try to read this is:

dim sInfile as String = OpenFile(True)
Dim fout As FileStream = DecryptFile(sInfile)
Try
Dim xmlRdr As New XmlTextReader(fout)
xmlRdr.XmlResolver = Nothing
dsXML.ReadXml(xmlRdr) <------------error here
Catch e As Exception
Console.WriteLine(e.ToString())
End Try

The error I'm getting is The root element is missing.

But, there has to be a way tor read this file. Access 2k3 has no problem
with missing root element.

What can I do to get this abomination running?

Thanks.
Nov 12 '05 #1
5 7994
Have you tried using dsXML.Read() instead?
Max

"Paul Nations" <pa***@adhe.arknet.nospam.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm in a real pickle. I've inherited a project with major problems. It
receives encrypted XML files from a website not under my control (so I
can't modify the web app) for insertion into a database. I'm under
intense pressure to get the data into the database NOW. I can decrypt the
files alright and they look like xml, they'll import into Access 2K3 with
no problem, but VB.Net will not read them. It's complaining about no root
element, and it's right there is no root element. I've tried manually
adding a root to the decrypted file but the remainder winds up unreadable.

Here is the top few lines of the decrypted file.
<dsFullStudentDataNew xmlns="NetFrameWork">
<student_table>
<ssn>000000000</ssn>
<first_name>rushmi</first_name>
<middle_initial>p</middle_initial>
<last_name>john</last_name>
<dob>11/12/1978</dob>
<gender>Female</gender>
<present_address>16 kavanaugh</present_address>

The code I'm using to try to read this is:

dim sInfile as String = OpenFile(True)
Dim fout As FileStream = DecryptFile(sInfile)
Try
Dim xmlRdr As New XmlTextReader(fout)
xmlRdr.XmlResolver = Nothing
dsXML.ReadXml(xmlRdr) <------------error here
Catch e As Exception
Console.WriteLine(e.ToString())
End Try

The error I'm getting is The root element is missing.

But, there has to be a way tor read this file. Access 2k3 has no problem
with missing root element.

What can I do to get this abomination running?

Thanks.

Nov 12 '05 #2
If the file is smallish you could read it all into a "string" using
StreamReader.ReadToEnd() then do this:

Dim reader as New StreamReader(fout); ' do you know the encoding? If so
pass it to the constructor here
Dim fixedXml = "<root>" + reader.ReadToEnd() + "</root>"
Dim xmlRdr As New XmlTextReader(new StringReader(fixedXml))

....

"Paul Nations" <pa***@adhe.arknet.nospam.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm in a real pickle. I've inherited a project with major problems. It
receives encrypted XML files from a website not under my control (so I
can't modify the web app) for insertion into a database. I'm under
intense pressure to get the data into the database NOW. I can decrypt the
files alright and they look like xml, they'll import into Access 2K3 with
no problem, but VB.Net will not read them. It's complaining about no root
element, and it's right there is no root element. I've tried manually
adding a root to the decrypted file but the remainder winds up unreadable.

Here is the top few lines of the decrypted file.
<dsFullStudentDataNew xmlns="NetFrameWork">
<student_table>
<ssn>000000000</ssn>
<first_name>rushmi</first_name>
<middle_initial>p</middle_initial>
<last_name>john</last_name>
<dob>11/12/1978</dob>
<gender>Female</gender>
<present_address>16 kavanaugh</present_address>

The code I'm using to try to read this is:

dim sInfile as String = OpenFile(True)
Dim fout As FileStream = DecryptFile(sInfile)
Try
Dim xmlRdr As New XmlTextReader(fout)
xmlRdr.XmlResolver = Nothing
dsXML.ReadXml(xmlRdr) <------------error here
Catch e As Exception
Console.WriteLine(e.ToString())
End Try

The error I'm getting is The root element is missing.

But, there has to be a way tor read this file. Access 2k3 has no problem
with missing root element.

What can I do to get this abomination running?

Thanks.

Nov 12 '05 #3
dataset.read()

does not seem to be a method of the dataset object.

Thanks anyway.
"Max Schneider, Image Innovation" <ma*@imageinnova-takethisout.com> wrote in
message news:Xs*******************@fe04.lga...
Have you tried using dsXML.Read() instead?
Max

"Paul Nations" <pa***@adhe.arknet.nospam.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm in a real pickle. I've inherited a project with major problems. It
receives encrypted XML files from a website not under my control (so I
can't modify the web app) for insertion into a database. I'm under
intense pressure to get the data into the database NOW. I can decrypt
the files alright and they look like xml, they'll import into Access 2K3
with no problem, but VB.Net will not read them. It's complaining about
no root element, and it's right there is no root element. I've tried
manually adding a root to the decrypted file but the remainder winds up
unreadable.

Here is the top few lines of the decrypted file.
<dsFullStudentDataNew xmlns="NetFrameWork">
<student_table>
<ssn>000000000</ssn>
<first_name>rushmi</first_name>
<middle_initial>p</middle_initial>
<last_name>john</last_name>
<dob>11/12/1978</dob>
<gender>Female</gender>
<present_address>16 kavanaugh</present_address>

The code I'm using to try to read this is:

dim sInfile as String = OpenFile(True)
Dim fout As FileStream = DecryptFile(sInfile)
Try
Dim xmlRdr As New XmlTextReader(fout)
xmlRdr.XmlResolver = Nothing
dsXML.ReadXml(xmlRdr) <------------error here
Catch e As Exception
Console.WriteLine(e.ToString())
End Try

The error I'm getting is The root element is missing.

But, there has to be a way tor read this file. Access 2k3 has no problem
with missing root element.

What can I do to get this abomination running?

Thanks.


Nov 12 '05 #4
That seems to have done it. All my files are small < 65K (so far). So I
should be able to use this for the remainder of the scholarship application
season. I'll need to redo the website and - well the entire system needs to
be scrapped and rewritten.

Thanks so much. The students will never know who helped them get their
scholarships.

Thanks.
"Chris Lovett" <so*****@nospam.please> wrote in message
news:we********************@comcast.com...
If the file is smallish you could read it all into a "string" using
StreamReader.ReadToEnd() then do this:

Dim reader as New StreamReader(fout); ' do you know the encoding? If so
pass it to the constructor here
Dim fixedXml = "<root>" + reader.ReadToEnd() + "</root>"
Dim xmlRdr As New XmlTextReader(new StringReader(fixedXml))

...

"Paul Nations" <pa***@adhe.arknet.nospam.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm in a real pickle. I've inherited a project with major problems. It
receives encrypted XML files from a website not under my control (so I
can't modify the web app) for insertion into a database. I'm under
intense pressure to get the data into the database NOW. I can decrypt
the files alright and they look like xml, they'll import into Access 2K3
with no problem, but VB.Net will not read them. It's complaining about
no root element, and it's right there is no root element. I've tried
manually adding a root to the decrypted file but the remainder winds up
unreadable.

Here is the top few lines of the decrypted file.
<dsFullStudentDataNew xmlns="NetFrameWork">
<student_table>
<ssn>000000000</ssn>
<first_name>rushmi</first_name>
<middle_initial>p</middle_initial>
<last_name>john</last_name>
<dob>11/12/1978</dob>
<gender>Female</gender>
<present_address>16 kavanaugh</present_address>

The code I'm using to try to read this is:

dim sInfile as String = OpenFile(True)
Dim fout As FileStream = DecryptFile(sInfile)
Try
Dim xmlRdr As New XmlTextReader(fout)
xmlRdr.XmlResolver = Nothing
dsXML.ReadXml(xmlRdr) <------------error here
Catch e As Exception
Console.WriteLine(e.ToString())
End Try

The error I'm getting is The root element is missing.

But, there has to be a way tor read this file. Access 2k3 has no problem
with missing root element.

What can I do to get this abomination running?

Thanks.


Nov 12 '05 #5
I see from another post that you found another way around the problem. I
also see that you mentioned dataset.read(); case is important in C++, and I
know that you're coding in VB...did you try dataset.Read()? I see it listed
as a method of XmlTextReader.
Regards,

Max
"Paul Nations" <pa***@adhe.arknet.nospam.edu> wrote in message
news:uO**************@tk2msftngp13.phx.gbl...
dataset.read()

does not seem to be a method of the dataset object.

Thanks anyway.
"Max Schneider, Image Innovation" <ma*@imageinnova-takethisout.com> wrote
in message news:Xs*******************@fe04.lga...
Have you tried using dsXML.Read() instead?
Max

"Paul Nations" <pa***@adhe.arknet.nospam.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm in a real pickle. I've inherited a project with major problems. It
receives encrypted XML files from a website not under my control (so I
can't modify the web app) for insertion into a database. I'm under
intense pressure to get the data into the database NOW. I can decrypt
the files alright and they look like xml, they'll import into Access 2K3
with no problem, but VB.Net will not read them. It's complaining about
no root element, and it's right there is no root element. I've tried
manually adding a root to the decrypted file but the remainder winds up
unreadable.

Here is the top few lines of the decrypted file.
<dsFullStudentDataNew xmlns="NetFrameWork">
<student_table>
<ssn>000000000</ssn>
<first_name>rushmi</first_name>
<middle_initial>p</middle_initial>
<last_name>john</last_name>
<dob>11/12/1978</dob>
<gender>Female</gender>
<present_address>16 kavanaugh</present_address>

The code I'm using to try to read this is:

dim sInfile as String = OpenFile(True)
Dim fout As FileStream = DecryptFile(sInfile)
Try
Dim xmlRdr As New XmlTextReader(fout)
xmlRdr.XmlResolver = Nothing
dsXML.ReadXml(xmlRdr) <------------error here
Catch e As Exception
Console.WriteLine(e.ToString())
End Try

The error I'm getting is The root element is missing.

But, there has to be a way tor read this file. Access 2k3 has no
problem with missing root element.

What can I do to get this abomination running?

Thanks.



Nov 12 '05 #6

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

Similar topics

4
by: Cheryl Gilbert | last post by:
I'm sending xml to a web service by building a string dynamically. When my web service tries to validate the xml with a schema, I'm getting the error "the root element is missing". If I use an xml...
3
by: Samem N via DotNetMonster.com | last post by:
Does anyone know how to solve this error? I dont know where it went wrong. Any help would be appreciated .Thanks ERROR ______ Description: An unhandled exception occurred during the execution...
2
by: cordata5 | last post by:
Hi I'm using the example posted on Ron Howard's site for encryting the body of an xml file located at http://www.gotdotnet.com/team/rhoward/ I'm running into trouble where i'm getting an error of...
2
by: Scott Emick | last post by:
I am still having issues with getting Root Element Missing instead of the actual error that the webservice call is supposed to be returning. I'm using VB .Net 2003. Has anyone else been able to...
8
by: VK | last post by:
Can be multiple instances of element used as the root element? That's a curly way of asking, but I did not come up with a better sentence, sorry. What I mean is with a document like: <?xml...
1
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...
0
by: Dave Hill | last post by:
Forgive a newbie question. I'm learning the .NET XML environment. In the walkthrough on using XML designer to create an xsd, there is no discussion of the root element of the target xml document....
1
by: hvs69 | last post by:
I am writing a little application in c# which requires application of XSL transform on a RSS feed from YouTube. Here is the relevant code HttpWebRequest myreq =...
0
by: Lalitha Yadav | last post by:
getting an error as root element missing while reading and xml doucement string path = Server.MapPath("~/App_Data/use1.xml"); DataSet DS = new DataSet(); DataTable dt...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
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
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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...

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.