By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

ERR: The root element is missing

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.