Im getting this error while trying to read a xml file that i receive from a
POST
heres the code:
Dim MyXmlReader As XmlTextReader
Dim strNodeResult As String
Dim NodeType As XmlNodeType
Dim objwriter As StreamWriter
Try
MyXmlReader = New XmlTextReader(R equest.InputStr eam)
Do While MyXmlReader.Rea d '*******ERROR HERE ********
NodeType = MyXmlReader.Nod eType
Select Case NodeType
'Case XmlNodeType.Xml Declaration
'strNodeResult += "XML Declaration :" & MyXmlReader.Nam e
& " " & MyXmlReader.Val ue
Case XmlNodeType.Ele ment
If MyXmlReader.Nam e = "Beer" Then
If MyXmlReader.Att ributeCount > 0 Then
Do While MyXmlReader.Mov eToNextAttribut e
strNodeResult += MyXmlReader.Nam e & ":"
& MyXmlReader.Val ue
Loop
End If
End If
'strNodeResult += "Element: " & MyXmlReader.Nam e
'Case XmlNodeType.Tex t
'strNodeResult += "- Value: " & MyXmlReader.Val ue
End Select
Loop
objwriter = New StreamWriter(Se rver.MapPath("i tem.txt"), True)
objwriter.Write Line(strNodeRes ult)
objwriter.Close ()
objwriter = Nothing
Catch ex As Exception
objwriter = New StreamWriter(Se rver.MapPath("e rror.txt"), True)
objwriter.Write Line(ex.Message & " " & ex.StackTrace)
objwriter.Close ()
objwriter = Nothing
End Try 3 5937
heres the error :
The data at the root level is invalid. Line 1, position 1.
"Korivo" wrote: Im getting this error while trying to read a xml file that i receive from a POST
heres the code:
Dim MyXmlReader As XmlTextReader Dim strNodeResult As String Dim NodeType As XmlNodeType Dim objwriter As StreamWriter
Try MyXmlReader = New XmlTextReader(R equest.InputStr eam) Do While MyXmlReader.Rea d '*******ERROR HERE ******** NodeType = MyXmlReader.Nod eType Select Case NodeType 'Case XmlNodeType.Xml Declaration 'strNodeResult += "XML Declaration :" & MyXmlReader.Nam e & " " & MyXmlReader.Val ue Case XmlNodeType.Ele ment If MyXmlReader.Nam e = "Beer" Then If MyXmlReader.Att ributeCount > 0 Then Do While MyXmlReader.Mov eToNextAttribut e strNodeResult += MyXmlReader.Nam e & ":" & MyXmlReader.Val ue Loop End If End If 'strNodeResult += "Element: " & MyXmlReader.Nam e 'Case XmlNodeType.Tex t 'strNodeResult += "- Value: " & MyXmlReader.Val ue End Select Loop objwriter = New StreamWriter(Se rver.MapPath("i tem.txt"), True) objwriter.Write Line(strNodeRes ult) objwriter.Close () objwriter = Nothing Catch ex As Exception objwriter = New StreamWriter(Se rver.MapPath("e rror.txt"), True) objwriter.Write Line(ex.Message & " " & ex.StackTrace) objwriter.Close () objwriter = Nothing End Try
Begin by examining the content of the Request.InputSt ream. Use a regular
StreamReader and dump it to a string variable to see if you get *nothing
but* a valid XML document.
My guess, which is also suggested by your exception, is that you'll get
some header info from the stream *before* your actual XML.
Best regards,
Magnus
"Korivo" <Ko****@discuss ions.microsoft. com> skrev i meddelandet
news:E8******** *************** ***********@mic rosoft.com... heres the error : The data at the root level is invalid. Line 1, position 1.
"Korivo" wrote:
Im getting this error while trying to read a xml file that i receive from a POST
heres the code:
Dim MyXmlReader As XmlTextReader Dim strNodeResult As String Dim NodeType As XmlNodeType Dim objwriter As StreamWriter
Try MyXmlReader = New XmlTextReader(R equest.InputStr eam) Do While MyXmlReader.Rea d '*******ERROR HERE ******** NodeType = MyXmlReader.Nod eType Select Case NodeType 'Case XmlNodeType.Xml Declaration 'strNodeResult += "XML Declaration :" & MyXmlReader.Nam e & " " & MyXmlReader.Val ue Case XmlNodeType.Ele ment If MyXmlReader.Nam e = "Beer" Then If MyXmlReader.Att ributeCount > 0 Then Do While MyXmlReader.Mov eToNextAttribut e strNodeResult += MyXmlReader.Nam e & ":" & MyXmlReader.Val ue Loop End If End If 'strNodeResult += "Element: " & MyXmlReader.Nam e 'Case XmlNodeType.Tex t 'strNodeResult += "- Value: " & MyXmlReader.Val ue End Select Loop objwriter = New StreamWriter(Se rver.MapPath("i tem.txt"), True) objwriter.Write Line(strNodeRes ult) objwriter.Close () objwriter = Nothing Catch ex As Exception objwriter = New StreamWriter(Se rver.MapPath("e rror.txt"), True) objwriter.Write Line(ex.Message & " " & ex.StackTrace) objwriter.Close () objwriter = Nothing End Try
Right on it Magnus, the xml that i was receiving was not 100% valid XML,
thanx o lot!
"Magnus" wrote: Begin by examining the content of the Request.InputSt ream. Use a regular StreamReader and dump it to a string variable to see if you get *nothing but* a valid XML document. My guess, which is also suggested by your exception, is that you'll get some header info from the stream *before* your actual XML.
Best regards, Magnus
"Korivo" <Ko****@discuss ions.microsoft. com> skrev i meddelandet news:E8******** *************** ***********@mic rosoft.com... heres the error : The data at the root level is invalid. Line 1, position 1.
"Korivo" wrote:
Im getting this error while trying to read a xml file that i receive from a POST
heres the code:
Dim MyXmlReader As XmlTextReader Dim strNodeResult As String Dim NodeType As XmlNodeType Dim objwriter As StreamWriter
Try MyXmlReader = New XmlTextReader(R equest.InputStr eam) Do While MyXmlReader.Rea d '*******ERROR HERE ******** NodeType = MyXmlReader.Nod eType Select Case NodeType 'Case XmlNodeType.Xml Declaration 'strNodeResult += "XML Declaration :" & MyXmlReader.Nam e & " " & MyXmlReader.Val ue Case XmlNodeType.Ele ment If MyXmlReader.Nam e = "Beer" Then If MyXmlReader.Att ributeCount > 0 Then Do While MyXmlReader.Mov eToNextAttribut e strNodeResult += MyXmlReader.Nam e & ":" & MyXmlReader.Val ue Loop End If End If 'strNodeResult += "Element: " & MyXmlReader.Nam e 'Case XmlNodeType.Tex t 'strNodeResult += "- Value: " & MyXmlReader.Val ue End Select Loop objwriter = New StreamWriter(Se rver.MapPath("i tem.txt"), True) objwriter.Write Line(strNodeRes ult) objwriter.Close () objwriter = Nothing Catch ex As Exception objwriter = New StreamWriter(Se rver.MapPath("e rror.txt"), True) objwriter.Write Line(ex.Message & " " & ex.StackTrace) objwriter.Close () objwriter = Nothing End Try This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alan Wang |
last post by:
Hi there,
I got this message ("The data at the root level is invalid. Line 1, position
1.") when I moved the application from my workstation to Windows 2003 web
server. But the wired thing the whole application works fine on my
workstation which running Windows xp prof sp 2 edition.
Please help me out
Thanks
|
by: MR |
last post by:
I get the following Exception "The data at the root level is invalid. Line
1, position 642" whenever I try to deserialize an incoming SOAP message. The
incoming message is formed well and its length is 642 bytes ( I have
appended it to the end of this message).
I suspect that the reason may have something to do with an incorrect
declaration of which class to de-serialize to.
In the attached code I substituted @@@@@@@ in the code below with...
|
by: XML newbie: Urgent pls help! |
last post by:
I am using VB.Net.
Asset List is a long array of AssetIds. I declare it as:
Dim AssetList(0) As Long
AssetList(0) = 47288
Now, I pass an array of AssetIDs as long from here into the following line:
doc.LoadXml(EDP.ExportPositions(g_SessionID, cmbStartDateandTime.Text,
cmbEndDateandTime.Text, AssetList).ToString) as per the
|
by: =?Utf-8?B?am1ncm8=?= |
last post by:
I created a web service in visual studio 2003, tested it with a sample.xml
file from a vendor we are using, and it worked exactly like it should. I
depoloyed it to our server, created a project calling the webservice with
the sample.xml file, and again it worked. Now the vendor is calling the web
service from their application and receiving the following error, and stating
that there is something with the Web Service or the SOAP Client...
|
by: paulnamroud |
last post by:
Hi all,
I wrote a stored procedure with ms sql 2005 which returns a string parameter. This parameter contains differents xml elements and it's well formated.
First, its works fine when i call my stored procedure with asp 3.0. I can display all the contents of this xml parameter with xsl.
But, when it comes to call this stored procedure with ASP.Net 2.0, it doesn't work. It returns the following error message:
"Data at the root level...
| |
by: johnsonkt |
last post by:
hi all ,
when m trying to validate my xml using xsd file it gives me the following error
"Data at the root level is invalid. Line 1, position 1"
i tried to open the XML file using IE and there are no errors and there are no blank space before the root element.the xml is created dynamically and it is send as a string to validate. the dynamically generated xml string is the following.
<?xml version="1.0" encoding="utf-8" ?>
...
|
by: ayemyat |
last post by:
Hi All,
I have a remoting service which consumes the web service in another server.
I have the following exception throw by the web service.
System.Xml.XmlException: The data at the root level is invalid. Line 1, position 1.
There is an error in XML document (0, 0).
<?xml version="1.0" encoding="utf-8"?>
<MSVBalanceEnquiry xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
|
by: Cirene |
last post by:
My ASP.NET project builds fine (VS2008). I added a new web deployment
project.
When I try to build it I get:
Data at the root level is invalid. Line1, position 1. (The file is
web.config, line 1, column 1, in my deploy project.)
I double click on the error and it shows this...
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|09 May 2008 01:16:09 -0000
|
by: Hamayun Khan |
last post by:
Hi I get the following error
Server Error in '/teachnetwork' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Data at the root level is invalid. Line 1,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |