Posted by Paul Lautman on 12/17/19 11:55
R. Rajesh Jeba Anbiah wrote:
> Paul Lautman wrote:
>> Within a subsection of an HTML document (not a complete page), there
>> will be a few spans with the class "room_headings"
>> e.g.
>> <span class="room_headings"> Double
>> Room</span>
>>
>> Can folks suggest some nice ways of extracting all the text contents
>> of such spans into a list (for use in a drop-down select list)?
>
> XPath can be used if the contents are valid XML:
> $xml = new SimpleXMLElement( '<foo><span
> class="room_headings">DoubleRoom</span> <span
> class="room_headings">DoubleRoom</span><span
> class="room_headings1">DoubleRoom</span></foo>');
> print_r($xml->xpath('//span[@class="room_headings"]'));
Sadly I doubt that they are valid XML. They are a middle section of an HTML
page. The normal HTML page header tags will not be present either.
I was wondering if there was a good preg call that could accomplish it?
[Back to original message]
|