Jump to content

Tipo

New Members
  • Posts

    2
  • Joined

  • Last visited

Tipo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, but how can I run several queries at once? My problem is that I have to combine the results. For example the first pattern shows me the "headline", while the rest fetch the content related to that "headline". So when I create the output I would like to know: --> this is my headline 1 --> and this my content to this headline --> this is my headline 2 --> and so on In simple steps: 1. Find headline x 2. Find content for headline x 3. return to step 1 and find next headline With my 4 patterns I will get every information I need but now I can't separate them. Do you have an example how to write more queries and run them while the first query is active? Is it possible to run subqueries? That would solve my problem immediately.
  2. How do I know which query hits my HTML DOM? Or how can I separate the results to each query? $xpath = new DomXPath($dom); $nodes = $xpath->query("//tr/td/div[@class='category']/a[1]/text() | //tr/td[@id='data']/div[@class='category_data']/text() | //tr/td[@id='data']/div[@class='category']/text() | //tr/td[@id='data']/div[@class='category']/span[@class='category_data']/text()"); header("Content-type: text/plain"); foreach ($nodes as $i => $node) { if ( ) // Query 1: //tr/td/div[@class='category']/a[1]/text() { output the content here } if ( ) // Query 2: //tr/td[@id='data']/div[@class='category_data']/text() ... and so on echo "Node($i): " . ltrim(rtrim($node->nodeValue)) . "<br> --> " . $node->nodeName . "\n"; } $node->nodeName seems to be wrong. I also tried other option from PHP.net but maybe it isn't possible.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.