2

I am getting XML parsing errors when some one puts a binary character '' in a text field. Is there any way to just encode this data in XML and decode it back when it is used by someone.

My Webs service is written using PHP

Should i use utf8_encode/decode methods in PHP?

I tried bin2hex (to encode) and then hexdec (to decode) but it is not working for all the characters for example, character set from other languages.

Sudhir
  • 523
  • 2
  • 6
  • 15
  • "Should i use utf8_encode/decode methods in PHP?" If you want characters from other languages to work, yes. Also serve your page with the utf-8 character encoding, then. –  Nov 28 '11 at 11:11

1 Answers1

0

If XML source is malformed, and your PHP have installed tidy module (--with-tidy),
try this :-

    /* src xml could be malform */
    $ops = array();
    $ops['input-xml']  =
    $ops['output-xml'] = TRUE;

    $tidy = new Tidy($source_file, $ops);
    $tidy->isXML();
    $tidy->cleanRepair();

This of course will try to clean and repair any malform in the XML,
which mean the after cleanRepair, both XML is not longer identical.

ajreal
  • 46,720
  • 11
  • 89
  • 119