Questions tagged [zend-dom-query]

Zend\Dom\Query provides mechanisms for querying XML and HTML and XHTML documents utilizing either XPath or CSS selectors.

From the official documentation :

Zend\Dom\Query provides mechanisms for querying XML and HTML and XHTML documents utilizing either XPath or CSS selectors. It was developed to aid with functional testing of MVC applications, but could also be used for rapid development of screen scrapers.

CSS selector notation is provided as a simpler and more familiar notation for web developers to utilize when querying documents with XML structures. The notation should be familiar to anybody who has developed Cascading Style Sheets or who utilizes Javascript toolkits that provide functionality for selecting nodes utilizing CSS selectors .

25 questions
4
votes
1 answer

Find and replace html(Zend_Dom_Query+createElement()): Call to a member function createElement() on a non-object

I need to find and replace some html elements inside an html code (I followed this answer: Getting an element from PHP DOM and changing its value), to do so I retrieve the content with: $transport = $observer->getTransport(); $html =…
Razorphyn
  • 1,314
  • 13
  • 37
2
votes
2 answers

PHP HTML DOM: How to select all visible/readable text?

I'm trying to scrape websites, modify all visible text (meaning: links, paragraphs, headlines, etc) by keeping the html structure and then render the 'new' page afterwards. Basically I want to scramble all readable text without destroying…
Mayko
  • 429
  • 1
  • 5
  • 16
2
votes
1 answer

Parse results from Zend_Dom_Query

I am trying to parse screen-scraped data using Zend_Dom_Query, but I am struggling how to apply it properly for my case, and all other answers I have seen on SO make assumptions that quite frankly scare me with their naiveté. A typical example is…
Peter M
  • 7,309
  • 3
  • 50
  • 91
2
votes
1 answer

Get first element using Zend_Dom_Query

I want to get the first element using Zend_Dom_Query Example I have 2 forms in document:
How can I get the first form? I tried this: $dom->query('form:eq(1)') like jQuery selector but not success. Can you help me? Thanks…
sondoha
  • 156
  • 6
1
vote
1 answer

Getting an element from PHP DOM and changing its value

I'm using PHP/Zend to load html into a DOM, and then I get a specific div id that I want to modify. $dom = new Zend_Dom_Query($html); $element = $dom->query('div[id="someid"]'); How do I modify the text/content/html displayed inside that $element…
sameold
  • 18,400
  • 21
  • 63
  • 87
1
vote
1 answer

XPath query to get HTML nodes with multiple classes, using PHP/Zend_Dom_Query?

It's very easy to get an HTML node using Zend_Dom_Query by class: $dom = new Zend_Dom_Query($html); $rows = $dom->query("//div[@class='upc']"); However, HTML nodes often have more than one class, e.g.:
Jason
  • 14,517
  • 25
  • 92
  • 153
1
vote
1 answer

Traversing through DOM element using PHP

I am useing Zend\Dom\Query to get specific content from a webpage. I have an html document like below
Foysal Vai
  • 1,365
  • 3
  • 13
  • 19
1
vote
2 answers

Using Zend\Dom\Query

I am useing Zend\Dom\Query to get specific content from a webpage. This is the html: How can I get the value Mouse ?? Thanks
Foysal Vai
  • 1,365
  • 3
  • 13
  • 19
1
vote
1 answer

DOM Query How to get the first levels of matching?

I need to take all matches on first level depth http://framework.zend.com/manual/2.0/en/modules/zend.dom.query.html It shows me all matches that contain class accordion + all child matches $dom = new Query($html); $results =…
Oyeme
  • 11,088
  • 4
  • 42
  • 65
1
vote
1 answer

How to Pass Array from Zend Dom Query Results to table

I am querying a URL for columns YEAR, RATING and I want to insert those two into a database. E.g. YEAR RATING 1992 9.2 2000 9 1999 8 . . . . . . . . So, I am writing script like: $url = 'BLA BLA '; $data = file_get_contents($url); $dom = new…
pancy1
  • 491
  • 7
  • 16
1
vote
2 answers

Zend Framework 1.12.3 Zend_Dom_Query can't load DOCTYPE xmls

I have switched my zend framework version from 1.11 to 1.12.3 In the tests i detect a strange error that i cannot explain. I have some xml fetch and processing routines that yell at me. PHP Fatal error: Uncaught exception 'Zend_Dom_Exception' with…
jami
  • 190
  • 2
  • 14
1
vote
2 answers

How can I use Zend_Dom_Query to get meta data

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…
David Sigley
  • 1,126
  • 2
  • 13
  • 28
0
votes
2 answers

Zend_Dom_Query query element issue

I have an issue where I have a div that doesnt have a class or id. Is it possible to select an div element when I know its innerText ie
Search on a this text
If not, the div before it has a class, how do i…
madphp
  • 1,716
  • 5
  • 31
  • 72
0
votes
1 answer

phpunit with Zend_Dom_Query

$domDoc = new DOMDocument(); $domDoc->loadHTML($docSrc); $xpath = new DOMXPath($domDoc); $nodeList = $xpath->query("//a[@class='active' and @href='/advanced-2-0.html']"); $this->assertTrue($nodeList->length == 1); This code works great if $docSrc…
Plootor
  • 61
  • 5
0
votes
1 answer

Using python to take advantage of web page functions

I am trying to understand how this web site is working. There is an input form where you can provide a url. This form returns information retrieved from another site (Youtube). So: My first and more interesting question is if anybody has any idea…
Thoth
  • 993
  • 12
  • 36
1
2