Connecting Tech Pros Worldwide Forums | Help | Site Map

ERR: The root element is missing

Paul Nations
Guest
 
Posts: n/a
#1: Nov 12 '05
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.



Max Schneider, Image Innovation
Guest
 
Posts: n/a
#2: Nov 12 '05

re: ERR: The root element is missing


Have you tried using dsXML.Read() instead?


Max

"Paul Nations" <pauln@adhe.arknet.nospam.edu> wrote in message
news:%23HTpz5taFHA.1152@tk2msftngp13.phx.gbl...[color=blue]
> 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.
>
>[/color]


Chris Lovett
Guest
 
Posts: n/a
#3: Nov 12 '05

re: ERR: The root element is missing


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" <pauln@adhe.arknet.nospam.edu> wrote in message
news:%23HTpz5taFHA.1152@tk2msftngp13.phx.gbl...[color=blue]
> 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.
>
>[/color]


Paul Nations
Guest
 
Posts: n/a
#4: Nov 12 '05

re: ERR: The root element is missing


dataset.read()

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

Thanks anyway.


"Max Schneider, Image Innovation" <max@imageinnova-takethisout.com> wrote in
message news:Xs6pe.49503$rt1.40691@fe04.lga...[color=blue]
> Have you tried using dsXML.Read() instead?
>
>
> Max
>
> "Paul Nations" <pauln@adhe.arknet.nospam.edu> wrote in message
> news:%23HTpz5taFHA.1152@tk2msftngp13.phx.gbl...[color=green]
>> 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.
>>
>>[/color]
>
>[/color]


Paul Nations
Guest
 
Posts: n/a
#5: Nov 12 '05

re: ERR: The root element is missing


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" <someone@nospam.please> wrote in message
news:weydnU2yhvQwojjfRVn-vQ@comcast.com...[color=blue]
> 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" <pauln@adhe.arknet.nospam.edu> wrote in message
> news:%23HTpz5taFHA.1152@tk2msftngp13.phx.gbl...[color=green]
>> 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.
>>
>>[/color]
>
>[/color]


Max Schneider, Image Innovation
Guest
 
Posts: n/a
#6: Nov 12 '05

re: ERR: The root element is missing


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" <pauln@adhe.arknet.nospam.edu> wrote in message
news:uOsvPa2aFHA.3488@tk2msftngp13.phx.gbl...[color=blue]
> dataset.read()
>
> does not seem to be a method of the dataset object.
>
> Thanks anyway.
>
>
> "Max Schneider, Image Innovation" <max@imageinnova-takethisout.com> wrote
> in message news:Xs6pe.49503$rt1.40691@fe04.lga...[color=green]
>> Have you tried using dsXML.Read() instead?
>>
>>
>> Max
>>
>> "Paul Nations" <pauln@adhe.arknet.nospam.edu> wrote in message
>> news:%23HTpz5taFHA.1152@tk2msftngp13.phx.gbl...[color=darkred]
>>> 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.
>>>
>>>[/color]
>>
>>[/color]
>
>[/color]


Closed Thread


Similar .NET Framework bytes