472,145 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 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 7878
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Cheryl Gilbert | last post: by
3 posts views Thread by Samem N via DotNetMonster.com | last post: by
reply views Thread by Dave Hill | last post: by

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.