By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

Xpath encoding problem

P: n/a

Hi,

I have the following code:

$d = xpath->query($myxpath);
$text = $d->item(0)->nodeValue;
print $text;

While this code is working well with English characters, non-English
characters (Hebrew, German, Russian) are not encoded properly and the
output is unreadable gibberish.

I know PHP XML DOM is Unicode, but even iconv or other functions
unable to display those characters as they should.
Feb 11 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a

Hi Rik and thanks for your quick help,

I did test your code and it is working, except one site.
The encoding on that site is the same like other sites (with correct
output encoding):

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

another different it has DTD of HTML 4 Transitional (others are XHTML
or missing DTD).

Any ideas?
Feb 11 '08 #2

P: n/a
On Mon, 11 Feb 2008 19:05:20 +0100, Moti <Mo*****@gmail.comwrote:
>
Hi Rik and thanks for your quick help,

I did test your code and it is working, except one site.
The encoding on that site is the same like other sites (with correct
output encoding):

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
Don't rely on META tags. What are the actual headers?
another different it has DTD of HTML 4 Transitional (others are XHTML
or missing DTD).
Should not be a problem.
--
Rik Wasmus
Feb 11 '08 #3

P: n/a
After debugging and comparing files, I found that if I insert

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

Before any other tags in <headthe encoding is OK, if not i got
gibberish.
Feb 11 '08 #4

P: n/a
On Mon, 11 Feb 2008 19:29:07 +0100, Moti <Mo*****@gmail.comwrote:
After debugging and comparing files, I found that if I insert

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

Before any other tags in <headthe encoding is OK, if not i got
gibberish.
Doing a header('Content-Type: text/html; charset=utf-8'); should take care
of that...
--
Rik Wasmus
Feb 11 '08 #5

P: n/a
On Feb 11, 9:11 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Mon, 11 Feb 2008 19:29:07 +0100, Moti <Moti...@gmail.comwrote:
After debugging and comparing files, I found that if I insert
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
Before any other tags in <headthe encoding is OK, if not i got
gibberish.

Doing a header('Content-Type: text/html; charset=utf-8'); should take care
of that...
--
Rik Wasmus
I meant adding that to html data grabbed from web site, not to my
page.

Feb 11 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.