Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8113011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:41:24+00:00 2026-06-06T02:41:24+00:00

I have a problem with accented letters. For example: I have a tag that

  • 0

I have a problem with accented letters.

For example:
I have a tag that contains: “il mio prodotto é molto bello”. However, the output is: “il mio prodotto “

When in xml, and there is an accented letter, the date is cut. I have a xml with:

<?xml version="1.0" encoding="utf-8"?>

Here is my parser code:

<?php
class Content_Handler {
   function Content_Handler(){}
   function start_element($parser, $name, $attrs) {
       global $desc, $names, $link;
       if ($name == "PRODUCT"){
          $zupid = ($attrs["ZUPID"]);
          echo "$zupid<br>";
       }
       if ($name == "DESCRIPTION") { $desc = true;}
       if ($name == "NAME") { $names = true;}
       if ($name == "DEEPLINK") { $link = true;}
   }

   function end_element($parser, $name) {
       if ($name == "PRODUCT") {
          print "<br />";
       }
   }


   function characters($parser, $chars) {
       global $desc, $names, $link;
       if ($desc) { echo $chars."<br>"; $desc = false;} 
       if ($names) { echo $chars."<br>"; $names = false;} 
       if ($link) { echo $chars."<br>"; $link = false;} 
   }
}


$handler = new Content_Handler();
$cat_parser = xml_parser_create("UTF-8");

xml_parser_set_option($cat_parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
xml_set_object($cat_parser, $handler);
xml_set_element_handler($cat_parser, "start_element", "end_element");
xml_set_character_data_handler($cat_parser, "characters");


$file = "my.xml";


if ($file_stream = fopen($file, "r")) {

   while ($data = fread($file_stream, 4096)) {

       $this_chunk_parsed = xml_parse($cat_parser, $data, feof($file_stream));
       if (!$this_chunk_parsed) {
           $error_code = xml_get_error_code($cat_parser);
           $error_text = xml_error_string($error_code);
           $error_line = xml_get_current_line_number($cat_parser);

           $output_text = "Parsing problem at line $error_line: $error_text";
           die($output_text);
       }
   }
} else {

    die("Can't open XML file.");

}
xml_parser_free($cat_parser);

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:41:25+00:00Added an answer on June 6, 2026 at 2:41 am

    This is the normal error when dealing with SAX parsing in what appears to be any language (see previous answers on java and C!).

    When you are a parsing SAX events, the Characters function isn’t the entire contents of the element between the start and end tag, it can be called many times, and when you are dealing with accented characters it is.

    The full characters contents can only be determined by concatinating the values between a start and end tags.

    so for your term ‘”il mio prodotto é molto bello’, characters will be called probably 3 times, with ‘il mio prodotto ‘, ‘é’ and ‘ molto bello’, so you need to concatinate them, not use them as litterals.

    Your ‘characters’ function should be more like:

    function characters($parser, $chars) {
       global $desc, $names, $link;
       $fullchars .= $chars;
    }
    

    with your chars being used and reset in the end_element and start_element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with sending mails that preserve accented characters. By reading some
I have problem with fancybox. I want to write a function that will run
i have problem with libhid . i found that there 2 way 4 accessing
I have an array I'm trying to asort using php. The problem is that
Quest I am looking to fetch rows that have accented characters. The encoding for
I have an ASP Access database that contains strings in various European languages. The
I have a problem that consist in comparing boolean expressions ( OR is +,
I have accented characters in my settings.py that I access in a view using
So I have this script that reads the xml, modifies the selected node value
I have a a strange problem that I can't seem to identify the cause

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.