Bluehost.com Web Hosting $6.95

DNL by value

This is a discussion on DNL by value within the PHP General forums, part of the PHP Programming Forums category; Hi everyone, I was wondering if there is a way to create a dnl (or an array?) with all the ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-26-2008
Luke
 
Posts: n/a
Default DNL by value

Hi everyone,

I was wondering if there is a way to create a dnl (or an array?) with all
the entries in an XML with a certain value in a certain tag in PHP DOM?

Thanks a lot.

Luke

Reply With Quote
  #2 (permalink)  
Old 08-27-2008
mrclay
 
Posts: n/a
Default Re: DNL by value

On Aug 26, 10:23*am, tinmach...@googlemail.com (Luke) wrote:
> I was wondering if there is a way to create a dnl (or an array?) with all
> the entries in an XML with a certain value in a certain tag in PHP DOM?


What do you mean by "entries" and "value"? It would help to use XML
terminology, e.g., do you want the content of all "strong" elements
with a "class" attribute?

You *can* query an XML doc with XPath: http://us.php.net/manual/en/domxpath..query.php
You'll get a DOMNodeList back, then, for each DOMNode you'd want to
normalize it, get the first child (hopefully a DOMText), and get that
object's "wholeText" property.

....which is why I'd probably just use a regular expression.

// not tested and not bulletproof, but will probably work
preg_match_all('@<strong\\s[^>]*?\\bclass=[\'"][^>]+>([\\s\\S]*?)</
strong>@', $xmlText, $m);

$m[1] will be an array of your strong contents..

Steve
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:42 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0