473,804 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Invalid hexadecimal character reference" error parsing an XML withSAX processor

Hy to everyone

I have created a simple SAX parser for a very simple XML file.

When I run the code that follows I get this error:

"Invalid hexadecimal character reference"

The strange thing is If I change the "chunk size" for the data I send
to the parser, the error row changes. This behaviour is very strange!

I have done a one more test and I have set the chunkSize equals to the
file size and I have the same error at the end of the file.

The same XML file processed with another language doesn't raise any
error.

I use PHP 5.2.3 and a LAMP (AppServ Open Project - 2.5.9 for Windows)
on
a Windows VISTA PC.

The code I have used follows:

public function create_parser($ filename)
{
$this->fp = fopen($filename , 'r');
$this->fsize = filesize($filen ame);
$this->parser = xml_parser_crea te();
xml_set_element _handler($this->parser,
'Parser::start_ element','Parse r::end_element' );
xml_set_charact er_data_handler ($this->parser, 'Parser::char_d ata');
}
public function parse()
{
//$blockSize = 4*1024;
$blockSize = $this->fsize; echo 'Lunghezza file: '.$this-
>fsize;
while ($data = fread($this->fp, $blockSize))
{
//$data = str_replace('\n ','',$data);
if (!xml_parse($th is->parser, $data, feof($this->fp)))
{
echo 'Parser error: ('.xml_get_curr ent_byte_index( $this-
>parser).')
\''.xml_error_s tring($this->parser).'\' at line '.
xml_get_current _line_number($t his->parser). ' at col ' .
xml_get_current _column_number( $this->parser);
return false;
}
}
return true;
}
A piece of the XML following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE dblp SYSTEM "dblp.dtd">
<dblp>
<incollection mdate="2002-01-03"
key="books/acm/kim95/AnnevelinkACFHK 95">
<author>
Jurgen Annevelink
</author>
<author>
Rafiul Ahad
</author>
<author>
Amelia Carlson
</author>
<author>
Daniel H. Fishman
</author>
<author>
Michael L. Heytens
</author>
<author>

.....
The Industrial Information Technology Handbook
</booktitle>
<url>
db/books/collections/IITHandbook2005 .html#SeyfarthK 05
</url>
</incollection>
</dblp>

Aug 5 '08 #1
0 1257

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

Similar topics

7
9038
by: Ensoul Chee | last post by:
I used #include <iostream.h> int m; cout << "Hexadecimal == 0x" << hex << m << endl; to print value of m in hexadecimal mode. But I got the compile error like this couttest.cpp:20 `hex' undeclared (first use this function)
38
5748
by: Haines Brown | last post by:
I'm having trouble finding the character entity for the French abbreviation for "number" (capital N followed by a small supercript o, period). My references are not listing it. Where would I find an answer to this question (don't find it in the W3C_char_entities document). -- Haines Brown brownh@hartford-hwp.com
6
6248
by: mihailsmilev | last post by:
Hello, let me first describe the situation: I am developing an application using Qt Designer 3.3.5 on OpenSuSE Linux for my mp3 player. So I need to get the id3 tags from the mp3 files, and I've downloaded the sources of id3lib. I've included the headers (there are no other files) in my project in Qt designer, then created an object from my files. When starting the make command, it compiles normally all the headers (although giving some...
1
2727
by: DCC700 | last post by:
After upgrading a web application from VS 2003 to 2005 there is a page where any control event that should cause a postback instead generates an Invalid character error on the page. For example a drop down list is set to AutoPostBack, and for OnSelectedIndexChanged should update the values of other drop down lists. This page works fine in VS 2003, and the other pages with similar controls are posting back fine in 2005. Has anyone else...
0
9706
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10337
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...
1
10323
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,...
0
10082
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...
1
7622
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
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
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...

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.