Zend_Dom query

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_Dom query

waigani-2
I'm trying to select every element that has the string 'url' inside its style attribute. The following does not work: $dom->query('*[style*="url"]').
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Dom query

weierophinney
Administrator
-- Waigani <[hidden email]> wrote
(on Sunday, 28 September 2008, 01:19 PM -0700):
> I'm trying to select every element that has the string 'url' inside its style
> attribute. The following does not work: $dom->query('*[style*="url"]').

Try without the leading '*':

    $dom->query('[style*="url"]')

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Dom query

waigani-2
In reply to this post by waigani-2
no luck I get a "DOMXPath::query() [function.DOMXPath-query]: Invalid expression in …" . Also I'm trying to grab the xml declaration with a reg - as there has been no feed back on grabbing it with Zend Dom. The following does not work:

$html = '<?xml version="1.0" encoding="iso-8859-1"?>';

$html = preg_replace( '/<\?.\?>/', 'replace xml', $html);

echo $html;

why does  '/<\?.\?>/' not work?

Waigani wrote
I'm trying to select every element that has the string 'url' inside its style attribute. The following does not work: $dom->query('*[style*="url"]').
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Dom query

waigani-2
worked out reg exp (I'm a newbie to reg exp) '/<\?.\?>/' should be  '/<\?.+\?>/'


Waigani wrote
no luck I get a "DOMXPath::query() [function.DOMXPath-query]: Invalid expression in …" . Also I'm trying to grab the xml declaration with a reg - as there has been no feed back on grabbing it with Zend Dom. The following does not work:

$html = '<?xml version="1.0" encoding="iso-8859-1"?>';

$html = preg_replace( '/<\?.\?>/', 'replace xml', $html);

echo $html;

why does  '/<\?.\?>/' not work?

Waigani wrote
I'm trying to select every element that has the string 'url' inside its style attribute. The following does not work: $dom->query('*[style*="url"]').
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Dom query

jasonistaken
I'd recommend making the "plus" lazy... ie: '/<\?.+?\?>/'
That way it will stop matching at the first time it sees a "?>" other
than the last time, which could produce unexpected results.


Waigani wrote:

> worked out reg exp (I'm a newbie to reg exp) '/<\?.\?>/' should be
> '/<\?.+\?>/'
>
>
>
> Waigani wrote:
>  
>> no luck I get a "DOMXPath::query() [function.DOMXPath-query]: Invalid
>> expression in …" . Also I'm trying to grab the xml declaration with a reg
>> - as there has been no feed back on grabbing it with Zend Dom. The
>> following does not work:
>>
>> $html = '<?xml version="1.0" encoding="iso-8859-1"?>';
>>
>> $html = preg_replace( '/<\?.\?>/', 'replace xml', $html);
>>
>> echo $html;
>>
>> why does  '/<\?.\?>/' not work?
>>
>>
>> Waigani wrote:
>>    
>>> I'm trying to select every element that has the string 'url' inside its
>>> style attribute. The following does not work:
>>> $dom->query('*[style*="url"]').
>>>
>>>      
>>    
>
>