Menu

#30 Clearer Help on How to use Attribute

v1.0_(example)
closed
None
2
2019-04-15
2014-07-26
Kardi
No

Can you give example on how to use attribute.

For instance, I have:

Updated: 11:33 pm (33 mins ago)


Updated: 11:32 pm (34 mins ago)


...
the id are changing but always contains word "datetime":
my goal is to get the updated time of the experiments (e.g. 11:33, 11:32). How to do that?

I want to get only the time but this does not work:
foreach($aLine->find('p[*=datetime]') as $stationTime){
$updateTime[]=$stationTime->plaintext . '
';
}

This also does not work (but this format is what you write in documentation):
foreach($aLine->find('p*=datetime') as $stationTime){
$updateTime[]=$stationTime->plaintext . '
';
}

Thanks

Discussion

  • LogMANOriginal

    LogMANOriginal - 2019-04-15
    • status: open --> closed
    • assigned_to: John Schlick --> LogMANOriginal
    • discussion: enabled --> disabled
     
  • LogMANOriginal

    LogMANOriginal - 2019-04-15

    Closing because this is an old topic which is probably of no importance today. Please don't hesitate to open a new ticket for further discussion.

    That said, your examples above need to be adjusted slightly to make them work:

    foreach($aLine->find('p[id*="datetime"]') as $stationTime){
        $updateTime[] = $stationTime->plaintext . '<br>'; 
    }
    

    The difference is simply in how the attribute is defined. The parser needs to know which attribute to look at:

    'p[*="datetime"]'
    'p[id*="datetime"]'