Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:40:24+00:00 2026-06-12T06:40:24+00:00

Using Zend_Dom_Query, I would like to retrieve meta data out of an HTML string.

  • 0

Using Zend_Dom_Query, I would like to retrieve meta data out of an HTML string.

to retrieve links you can simply query like so:

$results = $dom->query('a'); //Where $dom is your html string

Unfortunately this doesn’t seem to work with meta

$results = $dom->query('meta'); //doesn't work

How can I retrieve meta data and then filter by its ‘property’ attribute?

An example of what I’m looking for:

               public function meta($dom)
{
    $results = $dom->query('meta'); //This is not a correct query (does anyone have an alternative?)
    $links = array();
    foreach ($results as $index => $result) {
        if ($result->getAttribute('property') == 'title') { //find <meta property="title"
            echo $result->getAttribute('content') . '<br />'; //echo the content attribute of the title
        }
    }
    return $results;
}

This code would work once the query is correct. However I would like to take it a step further and query directly for <meta property="title" content="This is the Title" /> instead of retrieving all meta and looping around to get the right one.

Any help with either getting all meta data using zend_dom_query or (more importantly) querying to receive only the meta data where property == title would be appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:40:26+00:00Added an answer on June 12, 2026 at 6:40 am

    the meta tag in not a valid CSS selector so you have to use the $dom->queryXpath($xPathQuery) method instead of $dom->query().

    maybe something like:

    $dom->queryXpath('/html/head');
    

    I’m not sure of the exact query string to use, but this is the idea.

    Zend_Dom_Query Theory of Operation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to find out which strategy is the best for links, forms
Using Zend_Form, how would I create form elements like this <input type=text name=element[1] value=/>
I'm using Zend_DOM_Query to read HTML elements using DOM. <input type=text class=a> <input type=text
Using Zend_Form, how would I create form elements like this: <input type=text name=element[1] value=
Using Zend_Form, how would I create form elements like this: <input type=text name=element[0][name] value=
Using Zend DB. I am trying to figure out how to write this query
I'm using PHP/Zend to load html into a DOM, and then I get a
I'm using Zend_Cache to cache data generated from a web service. However, in the
I am using Zend Dom component to parse some Html blocks, but i have
I see lots of php libraries that can parse html. A nice example is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.