473,385 Members | 1,753 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,385 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 8012
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.