473,327 Members | 1,976 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,327 software developers and data experts.

To read an Xml file......

Am trying to read an xml file using vb.net but i'm getting following error.
Select XML file
Exception: {0}System.Xml.XmlException: This is an unexpected token. The expected token is 'QUOTE'. Line 1, position 11. at System.Xml.XmlScanner.ScanToken(Int32 expected) at System.Xml.XmlTextReader.SetLiteralValues(XmlAttri buteTokenInfo fld) at System.Xml.XmlTextReader.SetAttributeValues() at System.Xml.XmlTextReader.ParseElement() at System.Xml.XmlTextReader.Read() at Elsevier.Search.Btnsubmit_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\Elsevier\Search.aspx.vb:line 43

what is this?

My code is
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Btnsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsubmit.Click
  2.         Try
  3.             Dim reader As XmlTextReader
  4.             reader = New XmlTextReader("D:\Princy\My documents\gender.xml")
  5.             While reader.Read()
  6.                 If XmlNodeType.Element Then
  7.                     If reader.Name = "gender" Then
  8.                         Lblmsg.Text = reader.Value
  9.                     End If
  10.                 End If
  11.             End While
  12.             reader.Close()
  13.         Catch err As Exception
  14.             Lblmsg.Text = "Exception: {0}" & err.ToString()
  15.         End Try
  16.     End Sub
  17.  
Sep 11 '07 #1
2 2278
r035198x
13,262 8TB
Am trying to read an xml file using vb.net but i'm getting following error.
Select XML file
Exception: {0}System.Xml.XmlException: This is an unexpected token. The expected token is 'QUOTE'. Line 1, position 11. at System.Xml.XmlScanner.ScanToken(Int32 expected) at System.Xml.XmlTextReader.SetLiteralValues(XmlAttri buteTokenInfo fld) at System.Xml.XmlTextReader.SetAttributeValues() at System.Xml.XmlTextReader.ParseElement() at System.Xml.XmlTextReader.Read() at Elsevier.Search.Btnsubmit_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\Elsevier\Search.aspx.vb:line 43

what is this?

My code is
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Btnsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsubmit.Click
  2.         Try
  3.             Dim reader As XmlTextReader
  4.             reader = New XmlTextReader("D:\Princy\My documents\gender.xml")
  5.             While reader.Read()
  6.                 If XmlNodeType.Element Then
  7.                     If reader.Name = "gender" Then
  8.                         Lblmsg.Text = reader.Value
  9.                     End If
  10.                 End If
  11.             End While
  12.             reader.Close()
  13.         Catch err As Exception
  14.             Lblmsg.Text = "Exception: {0}" & err.ToString()
  15.         End Try
  16.     End Sub
  17.  
Moved to .NET forum
Sep 11 '07 #2
It was the mistake of xml file........
Sep 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Yang Li Ke | last post by:
Hi guys! I have some datas that I must check everytime a visitor comes to my site What is better to do: 1- Read data from a file or 2- Read data from a mysql db Thank you
10
by: ZafT | last post by:
Thanks in advance for any tips that might get me going in the right direction. I am working on a simple exercise for school that is supposed to use read to read a file (about 10 MB). I am...
1
by: cnu | last post by:
My program generates a log file for every event that happens in the program. So, I open the file and keep it open till the end. This is how I open the file for writing: <CODE> public...
4
by: ESPN Lover | last post by:
Below is two snippets of code from MSDN showing how to read a file. Is one way preferred over the other and why? Thanks. using System; using System.IO; class Test { public static void...
8
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
5
by: lovecreatesbea... | last post by:
The condition at line 31 is added to check if the program finished to read the whole file. Is it needed and correct? Thank you. #include <fstream> #include <iostream> #include <string> using...
0
by: lovecarole | last post by:
hi, i am the student who should write a program about reading wav file and do the DFT. actually i don't know how to read data of the wav song and save it into the array... if i want to read...
6
by: Thomas Kowalski | last post by:
Hi, currently I am reading a huge (about 10-100 MB) text-file line by line using fstreams and getline. I wonder whether there is a faster way to read a file line by line (with std::string line)....
9
by: flebber | last post by:
I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b") and write it out . the compressed "*.k3b" file has two file and the one I was trying...
2
by: Kevin Ar18 | last post by:
I posted this on the forum, but nobody seems to know the solution: http://python-forum.org/py/viewtopic.php?t=5230 I have a zip file that is several GB in size, and one of the files inside of it...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.