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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |