473,883 Members | 1,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>DE L_One</DEALER_CODE>
<BRAND>Bridgest one</BRAND>
<HIERARCHY>HAR0 01</HIERARCHY>
<NET_PRICE>123. 12</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>2 </ITM_NUMBER>
<MATERIAL>002 </MATERIAL>
<DEALER_CODE>DE L_Two</DEALER_CODE>
<BRAND>Fireston e</BRAND>
<HIERARCHY>HAR0 02</HIERARCHY>
<NET_PRICE>453. 12</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>3 </ITM_NUMBER>
<MATERIAL>003 </MATERIAL>
<DEALER_CODE />
<BRAND>FIRESTON E</BRAND>
<HIERARCHY>HAR0 01</HIERARCHY>
<NET_PRICE>24.1 2</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
</CHECK_ITEM_OUT>

When I am trying to read the <BRAND>FIRESTON E</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.Bra nd =
xmlTextReader.R eadElementConte ntAsString();
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 3324
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*********@gm ail.comwrote in message
news:11******** **************@ a34g2000cwb.goo glegroups.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>DE L_One</DEALER_CODE>
<BRAND>Bridgest one</BRAND>
<HIERARCHY>HAR0 01</HIERARCHY>
<NET_PRICE>123. 12</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>2 </ITM_NUMBER>
<MATERIAL>002 </MATERIAL>
<DEALER_CODE>DE L_Two</DEALER_CODE>
<BRAND>Fireston e</BRAND>
<HIERARCHY>HAR0 02</HIERARCHY>
<NET_PRICE>453. 12</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>3 </ITM_NUMBER>
<MATERIAL>003 </MATERIAL>
<DEALER_CODE />
<BRAND>FIRESTON E</BRAND>
<HIERARCHY>HAR0 01</HIERARCHY>
<NET_PRICE>24.1 2</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
</CHECK_ITEM_OUT>

When I am trying to read the <BRAND>FIRESTON E</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.Bra nd =
xmlTextReader.R eadElementConte ntAsString();
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...@fitzm e.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...@gm ail.comwrote in message

news:11******** **************@ a34g2000cwb.goo glegroups.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>DE L_One</DEALER_CODE>
<BRAND>Bridgest one</BRAND>
<HIERARCHY>HAR0 01</HIERARCHY>
<NET_PRICE>123. 12</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>2 </ITM_NUMBER>
<MATERIAL>002 </MATERIAL>
<DEALER_CODE>DE L_Two</DEALER_CODE>
<BRAND>Fireston e</BRAND>
<HIERARCHY>HAR0 02</HIERARCHY>
<NET_PRICE>453. 12</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>3 </ITM_NUMBER>
<MATERIAL>003 </MATERIAL>
<DEALER_CODE />
<BRAND>FIRESTON E</BRAND>
<HIERARCHY>HAR0 01</HIERARCHY>
<NET_PRICE>24.1 2</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
</CHECK_ITEM_OUT>

When I am trying to read the <BRAND>FIRESTON E</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.Bra nd =
xmlTextReader.R eadElementConte ntAsString();
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(re sponseStream);

streamWriter.Wr ite(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 = GetResponseStre am(uri,
searchRequestXM L);
System.Text.UTF 8Encoding ob = new UTF8Encoding();
byte[] arr2 = ob.GetBytes(res ponseXml);
responseStream. Write(arr2,0,ar r2.Length);
responseStream. Seek(0, SeekOrigin.Begi n);
XmlTextReader xmlTextReader = new
XmlTextReader(r esponseStream)


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...@gm ail.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...@fitzm e.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...@gm ail.comwrote in message
news:11******** **************@ a34g2000cwb.goo glegroups.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>DE L_One</DEALER_CODE>
<BRAND>Bridgest one</BRAND>
<HIERARCHY>HAR0 01</HIERARCHY>
<NET_PRICE>123. 12</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>2 </ITM_NUMBER>
<MATERIAL>002 </MATERIAL>
<DEALER_CODE>DE L_Two</DEALER_CODE>
<BRAND>Fireston e</BRAND>
<HIERARCHY>HAR0 02</HIERARCHY>
<NET_PRICE>453. 12</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
<ITEM id="">
<!-- id = [material] -->
<ITM_NUMBER>3 </ITM_NUMBER>
<MATERIAL>003 </MATERIAL>
<DEALER_CODE />
<BRAND>FIRESTON E</BRAND>
<HIERARCHY>HAR0 01</HIERARCHY>
<NET_PRICE>24.1 2</NET_PRICE>
<CURRENCY>EUR O</CURRENCY>
</ITEM>
</CHECK_ITEM_OUT>
When I am trying to read the <BRAND>FIRESTON E</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.Bra nd =
xmlTextReader.R eadElementConte ntAsString();
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
3589
by: Marian Jancar | last post by:
Hi, Is there a module for parsing spec files available? Marian -- -- Best Regards,
4
12011
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 XmlDocument doc.Load("C:\Projects\SQLXML\corc.xml") I get the following error: "System.Xml.XmlException: An unexpected end of file parsing CDATA has
2
2102
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
8885
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 which is Microsoft Word Document based on the extension or what ever it needs to figure out the type so i can display it in a program? also is there a simple way to get the icon of the file type? I've seen complex ways before, but is there any...
3
1681
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 defined in multiple places;" I know that I have two controls EditForm, in different namespaces, but with same file name: "EditForm_ascx" If it is of any importance, I use both user controls on same page.
1
2469
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 and drawing instructions like "move to's" and "change color's" optionally followed by one or more numeric (int or float) arguments. My problem is that the parsing algorithm I've currently implemented is extremely slow.
11
2849
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 to a webpage where viewers can read the rest of the article: This is the first few characters of text from my file.......<a href="article-to-read.aspx"> MORE </a> ...I also need to do some in file parsing where I start at one known keyword (START...
3
13023
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: “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>
4
1886
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 log file.Its hard to explain the issue.but shortly I can say that the reports has a unique report no. and this report number is located at the 3rd line and at the end of the report.How can I parse these reports?(I need all of the lines like below.) It...
0
9942
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9792
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,...
0
11142
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, 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...
0
10745
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 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...
0
10417
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9575
agi2029
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 projectplanning, coding, testing, and deploymentwithout 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...
1
7972
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5798
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.