Adam Jensen-2 wrote:
>
> Done (http://framework.zend.com/issues/browse/ZF-3938) and done
> (http://framework.zend.com/issues/browse/ZF-3939).
>
> Thanks!
> Adam
>
> On Tue, Aug 12, 2008 at 4:21 PM, Matthew Weier O'Phinney
> <matthew@zend.com> wrote:
>> -- Adam Jensen <jazzslider@gmail.com> wrote
>> (on Tuesday, 12 August 2008, 04:04 PM -0500):
>>> I've been experimenting with Zend_Dom_Query lately as an easier way to
>>> traverse and manipulate complicated HTML and XML documents. However,
>>> I've run into a character encoding issue I can't seem to solve:
>>>
>>> [reproduce code]
>>> $string = '<ul><li>каркас</li><li class="remove">библиотека</li></ul>';
>>> $queryObject = new Zend_Dom_Query($string);
>>> $queryResult = $queryObject->query('li.remove');
>>> $domElement = $queryResult->current();
>>> $domElement->parentNode->removeChild($domElement);
>>> echo $domElement->ownerDocument->saveHTML();
>>> [/reproduce code]
>>>
>>> [expected result]
>>> <ul><li>каркас</li></ul>
>>> [/expected result]
>>>
>>> [actual result]
>>> <ul><li>каркас</li></ul>
>>> [/actual result]
>>>
>>> I've run into this problem before when I was just using DOMDocument
>>> and DOMXPath, and was able to solve it by setting the encoding of the
>>> DOMDocument object to 'utf-8' right when I constructed it. However,
>>> Zend_Dom_Query doesn't provide a means of setting or retrieving the
>>> encoding used to interpret the underlying document. Is there a way to
>>> do this that I'm not seeing?
>>
>> No -- but it would be a good feature to have. Please place an issue in
>> the tracker for it.
>>
>>> Incidentally, I was also thinking it might be useful to modify the
>>> Zend_Dom_Query constructor so that it can accept an existing
>>> DOMDocument object, much like in the constructor for DOMXPath. E.g.,
>>>
>>> [code]
>>> $domObject = new DOMDocument('1.0', 'utf-8');
>>> $domObject->loadHTML('<ul><li>каркас</li><li
>>> class="remove">библиотека</li></ul>');
>>> $queryObject = new Zend_Dom_Query($domObject);
>>> $queryResult = $queryObject->query('li.remove');
>>> $domElement = $queryResult->current();
>>> $domElement->parentNode->removeChild($domElement);
>>> echo $domObject->saveHTML();
>>> [/code]
>>>
>>> It looks a bit over-complicated in this contrived, simple
>>> example...but in real-world applications, this would allow a bit more
>>> flexibility in terms of how the document object is initialized. Does
>>> this seem like a good idea?
>>
>> Yep. Add an feature request for this to the tracker as well. :)
>>
>> Glad somebody's using this stuff!
>>
>> --
>> Matthew Weier O'Phinney
>> Software Architect | matthew@zend.com
>> Zend Framework | http://framework.zend.com/
>>
>
>
--
View this message in context: http://www.nabble.com/Encoding-issues-with-Zend_Dom_Query-tp18952575p25530717.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论