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

Strange!! Unexpected end of file while parsing Name has occurred

Hi Group,

I am facing a strange problem here:
I am trying to read xml response from a servlet using XmlTextWriter.
I am able to read the read half of the xml and suddenly an exception:
“Unexpected end of file while parsing Name has occurred” isbeing
thrown.

Following is the part o xml I am trying to read:
<CHECK_ITEM_OUT>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>1</ITM_NUMBER>
<MATERIAL>001</MATERIAL>
<DEALER_CODE>DEL_One</DEALER_CODE>
<BRAND>Bridgestone</BRAND>
<HIERARCHY>HAR001</HIERARCHY>
<NET_PRICE>123.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>2</ITM_NUMBER>
<MATERIAL>002</MATERIAL>
<DEALER_CODE>DEL_Two</DEALER_CODE>
<BRAND>Firestone</BRAND>
<HIERARCHY>HAR002</HIERARCHY>
<NET_PRICE>453.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>3</ITM_NUMBER>
<MATERIAL>003</MATERIAL>
<DEALER_CODE />
<BRAND>FIRESTONE</BRAND>
<HIERARCHY>HAR001</HIERARCHY>
<NET_PRICE>24.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
</CHECK_ITEM_OUT>

When I am trying to read the <BRAND>FIRESTONE</BRAND(In Third item
in the list), I am getting the “Unexpected end of file while parsing
Name has occurred” exception. I am able to read the values from
<BRANDelement for first two elements.
Following is the code I am using for reading the xml.

case "BRAND":
if (!xmlTextReader.IsEmptyElement)
productInfo.Brand =
xmlTextReader.ReadElementContentAsString();
break;

I also have searched net for this problem but I found nothing useful

Please let me know if I am doing something wrong or missing on
something.

Thanks,
Anup Daware

Feb 6 '07 #1
3 3267
Something to consider, is look at the Dealer_code element. Maybe try
changing it from <DEALER_CODE />
to <DEALER_CODE></DEALER_CODE>, maybe even putting some test value in
there. That's the only thing I can see different in the XML document that
may cause something strange and it does occur just before the brand element.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Anup Daware" <an*********@gmail.comwrote in message
news:11**********************@a34g2000cwb.googlegr oups.com...
Hi Group,

I am facing a strange problem here:
I am trying to read xml response from a servlet using XmlTextWriter.
I am able to read the read half of the xml and suddenly an exception:
"Unexpected end of file while parsing Name has occurred" is being
thrown.

Following is the part o xml I am trying to read:
<CHECK_ITEM_OUT>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>1</ITM_NUMBER>
<MATERIAL>001</MATERIAL>
<DEALER_CODE>DEL_One</DEALER_CODE>
<BRAND>Bridgestone</BRAND>
<HIERARCHY>HAR001</HIERARCHY>
<NET_PRICE>123.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>2</ITM_NUMBER>
<MATERIAL>002</MATERIAL>
<DEALER_CODE>DEL_Two</DEALER_CODE>
<BRAND>Firestone</BRAND>
<HIERARCHY>HAR002</HIERARCHY>
<NET_PRICE>453.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>3</ITM_NUMBER>
<MATERIAL>003</MATERIAL>
<DEALER_CODE />
<BRAND>FIRESTONE</BRAND>
<HIERARCHY>HAR001</HIERARCHY>
<NET_PRICE>24.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
</CHECK_ITEM_OUT>

When I am trying to read the <BRAND>FIRESTONE</BRAND(In Third item
in the list), I am getting the "Unexpected end of file while parsing
Name has occurred" exception. I am able to read the values from
<BRANDelement for first two elements.
Following is the code I am using for reading the xml.

case "BRAND":
if (!xmlTextReader.IsEmptyElement)
productInfo.Brand =
xmlTextReader.ReadElementContentAsString();
break;

I also have searched net for this problem but I found nothing useful?

Please let me know if I am doing something wrong or missing on
something.

Thanks,
Anup Daware
Feb 6 '07 #2
Hi Mark,

Thanks for the reply and good observation too :)

I haven't included whole xml here. And I have elements like
<NET_PRICE/prior to <DEALER_CODE/in actual xml, this works fine.

By the way I also tried it with <DEALER_CODE></DEALER_CODEand with
some dummy value in it, but problem didn't solve.
Thanks,
Anup

On Feb 6, 8:09 pm, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Something to consider, is look at the Dealer_code element. Maybe try
changing it from <DEALER_CODE />
to <DEALER_CODE></DEALER_CODE>, maybe even putting some test value in
there. That's the only thing I can see different in the XML document that
may cause something strange and it does occur just before the brand element.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Anup Daware" <anup.daw...@gmail.comwrote in message

news:11**********************@a34g2000cwb.googlegr oups.com...
Hi Group,

I am facing a strange problem here:
I am trying to read xml response from a servlet using XmlTextWriter.
I am able to read the read half of the xml and suddenly an exception:
"Unexpected end of file while parsing Name has occurred" is being
thrown.

Following is the part o xml I am trying to read:
<CHECK_ITEM_OUT>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>1</ITM_NUMBER>
<MATERIAL>001</MATERIAL>
<DEALER_CODE>DEL_One</DEALER_CODE>
<BRAND>Bridgestone</BRAND>
<HIERARCHY>HAR001</HIERARCHY>
<NET_PRICE>123.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>2</ITM_NUMBER>
<MATERIAL>002</MATERIAL>
<DEALER_CODE>DEL_Two</DEALER_CODE>
<BRAND>Firestone</BRAND>
<HIERARCHY>HAR002</HIERARCHY>
<NET_PRICE>453.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>3</ITM_NUMBER>
<MATERIAL>003</MATERIAL>
<DEALER_CODE />
<BRAND>FIRESTONE</BRAND>
<HIERARCHY>HAR001</HIERARCHY>
<NET_PRICE>24.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
</CHECK_ITEM_OUT>

When I am trying to read the <BRAND>FIRESTONE</BRAND(In Third item
in the list), I am getting the "Unexpected end of file while parsing
Name has occurred" exception. I am able to read the values from
<BRANDelement for first two elements.
Following is the code I am using for reading the xml.

case "BRAND":
if (!xmlTextReader.IsEmptyElement)
productInfo.Brand =
xmlTextReader.ReadElementContentAsString();
break;

I also have searched net for this problem but I found nothing useful?

Please let me know if I am doing something wrong or missing on
something.

Thanks,
Anup Daware

Feb 7 '07 #3
Hi Group,

The problem is solved :)

Following lines were creating the problem:

StreamWriter streamWriter = new StreamWriter(responseStream);

streamWriter.Write(responseXml); //responseXml is a string

The the default buffer of StreamWriter is 4kb and the string
responseXml is more than that, thus only a portion of my xml was being
used by XmlTextWriter which is using responseStream: And that was the
reason of Unexpected end of file while parsing Name has occurred
exception.

Solution:
Rather than using the the StreamWriter, I directly used the
responseStream.Write; for this I converted the string to byte array.
Following is the code for it.

String responseXml = GetResponseStream(uri,
searchRequestXML);
System.Text.UTF8Encoding ob = new UTF8Encoding();
byte[] arr2 = ob.GetBytes(responseXml);
responseStream.Write(arr2,0,arr2.Length);
responseStream.Seek(0, SeekOrigin.Begin);
XmlTextReader xmlTextReader = new
XmlTextReader(responseStream)


Well the conclusion is StreamWriter has a default size of 4KB which is
not increased dynamically, and this is really unexpected.

Best Regards,
Anup Daware
On Feb 7, 8:42 am, "Anup Daware" <anup.daw...@gmail.comwrote:
Hi Mark,

Thanks for the reply and good observation too :)

I haven't included whole xml here. And I have elements like
<NET_PRICE/prior to <DEALER_CODE/in actual xml, this works fine.

By the way I also tried it with <DEALER_CODE></DEALER_CODEand with
some dummy value in it, but problem didn't solve.

Thanks,
Anup

On Feb 6, 8:09 pm, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Something to consider, is look at the Dealer_code element. Maybe try
changing it from <DEALER_CODE />
to <DEALER_CODE></DEALER_CODE>, maybe even putting some test value in
there. That's the only thing I can see different in the XML document that
may cause something strange and it does occur just before the brand element.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Anup Daware" <anup.daw...@gmail.comwrote in message
news:11**********************@a34g2000cwb.googlegr oups.com...
Hi Group,
I am facing a strange problem here:
I am trying to read xml response from a servlet using XmlTextWriter.
I am able to read the read half of the xml and suddenly an exception:
"Unexpected end of file while parsing Name has occurred" is being
thrown.
Following is the part o xml I am trying to read:
<CHECK_ITEM_OUT>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>1</ITM_NUMBER>
<MATERIAL>001</MATERIAL>
<DEALER_CODE>DEL_One</DEALER_CODE>
<BRAND>Bridgestone</BRAND>
<HIERARCHY>HAR001</HIERARCHY>
<NET_PRICE>123.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>2</ITM_NUMBER>
<MATERIAL>002</MATERIAL>
<DEALER_CODE>DEL_Two</DEALER_CODE>
<BRAND>Firestone</BRAND>
<HIERARCHY>HAR002</HIERARCHY>
<NET_PRICE>453.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>3</ITM_NUMBER>
<MATERIAL>003</MATERIAL>
<DEALER_CODE />
<BRAND>FIRESTONE</BRAND>
<HIERARCHY>HAR001</HIERARCHY>
<NET_PRICE>24.12</NET_PRICE>
<CURRENCY>EURO</CURRENCY>
</ITEM>
</CHECK_ITEM_OUT>
When I am trying to read the <BRAND>FIRESTONE</BRAND(In Third item
in the list), I am getting the "Unexpected end of file while parsing
Name has occurred" exception. I am able to read the values from
<BRANDelement for first two elements.
Following is the code I am using for reading the xml.
case "BRAND":
if (!xmlTextReader.IsEmptyElement)
productInfo.Brand =
xmlTextReader.ReadElementContentAsString();
break;
I also have searched net for this problem but I found nothing useful?
Please let me know if I am doing something wrong or missing on
something.
Thanks,
Anup Daware

Feb 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marian Jancar | last post by:
Hi, Is there a module for parsing spec files available? Marian -- -- Best Regards,
4
by: sunil | last post by:
I am creating a XML document which opens fine in IE. Implies MSXML thinks it is a well formed document. But when I try to load this document in VB.net using the following code Dim doc As New...
2
by: Bruce Sam | last post by:
Only I want to do is when I input a file's name in command line,the program can change the name by specified one.Could you give me some methods to do it?
2
by: Brian Henry | last post by:
I want to list out a directory listing along with showing the file type name (like explorer does when it says something like "MyDoc.DOC - Microsoft Word Document" How do I get that file type name...
3
by: MilanB | last post by:
Hello I'm asking is it possible that two or more Web User Control have same file (.ascx) name within same project? Namespace is different. I got error message: "CS1595: 'ASP.EditForm_ascx' is...
1
by: Christoph Bisping | last post by:
Hello! Maybe someone is able to give me a little hint on this: I've written a vb.net app which is mainly an interpreter for specialized CAD/CAM files. These files mainly contain simple movement...
11
by: .Net Sports | last post by:
In VB.net, I'm trying to do a couple of things in a couple of different blocks of code. I need to take the first 25 characters of a text file, then append at the end some ellipses and a MORE link...
3
by: Anup Daware | last post by:
Hi Group, I am facing a strange problem here: I am trying to read xml response from a servlet using XmlTextWriter. I am able to read the read half of the xml and suddenly an exception:...
4
by: DjLethal | last post by:
Hey Guys.I am a newbie on Perl.And I have a question about file parsing by perl. I have a log file which contains reports about a communication machine.I need to take some of the reports from the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
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...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shllpp 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

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.