FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Problem with appendChild and ellipsis...
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Problem with appendChild and ellipsis... [message #173099 is a reply to message #173077] Mon, 21 March 2011 08:26 Go to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
Senior Member
El 20/03/2011 19:24, Dennis escribió/wrote:
> On Sun, 20 Mar 2011 13:14:29 -0400, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> Can you post the actual code which is failing (or, if it's too long, a
>> complete example of the failure)?
>
> Here's a short sample that illustrates the problem...
>
> <?php
>
> foo();
> echo "test done<br>";
> exit;
>
> function foo()
> {
> $doc = new DOMDocument();
> $doc->formatOutput = true;
>
> $title = $doc->createElement("title");
> $doc->appendChild($title);
>
> $title_data = "Some data followed by an ellipses…";
>
> $title_text = $doc->createTextNode($title_data);
> $title->appendChild($title_text);
>
> $doc->saveXML();
> $doc->save("test.xml");
>
> echo "foo done<br>";
> }
>
> ?>

If I run this code I get this file:

<?xml version="1.0"?>
<title>Some data followed by an ellipses&#x2026;</title>

.... where &#x2026; is the entity for ellipsis.

My guess is that you are feeding createTextNode() with the wrong encoding:

http://es2.php.net/manual/en/intro.dom.php

«The DOM extension uses UTF-8 encoding. Use utf8_encode() and
utf8_decode() to work with texts in ISO-8859-1 encoding or Iconv for
other encodings. »



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: PHP Module Writing Help
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 22:16:52 GMT 2024

Total time taken to generate the page: 0.03775 seconds