php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55396 DOMXpath doesn't return everything, when reading certain HTML pages
Submitted: 2011-08-11 07:17 UTC Modified: 2014-12-30 10:41 UTC
From: anticom at hotmail dot de Assigned:
Status: No Feedback Package: DOM XML related
PHP Version: Irrelevant OS: debian lenny13
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-08-11 07:17 UTC] anticom at hotmail dot de
Description:
------------
when using DOMXpath class to get all links (using '//a'), on certain pages not all links get returned. I ran the script on my local testserver as well with php version 5.3.5 as well but it didn't work out either. The strange thing is that on viper-7's codepad the script is running just fine ( http://codepad.viper-7.com/m8IM9b ). He's using libxml version 2.6.26, on our production server 2.6.32 and on my local machine even 2.7.7.

Test script:
---------------
<?php
$url = 'http://home.immobilienscout24.de/289805/offers/Habitation/listed/Aktualität/0';
//$url = 'http://www.3-eck-immobilien.de/index.php?ziel=Immobilien&target=1&seite=1';

libxml_use_internal_errors(true);
$dom = new DOMDocument/*('1.0', 'iso-8859-1')*/;  //tried to pass the encoding because when not using libxml_use_internal_errors(true) a warning is echo'd saying that there was an issue with the encoding of the site but that didn't help
$dom->loadHTMLFile($url);
$dom->normalizeDocument();
libxml_clear_errors();

$xpath = new DOMXpath($dom);
//$tmpObj = $xpath->query('/html/body//a');
$tmpObj = $xpath->query('//a');

echo "<pre>\n";
foreach($tmpObj as $domnode) {
    echo "url: " . utf8_decode($domnode->attributes->getNamedItem('href')->nodeValue) . "\n";
    echo "content: " . utf8_decode($domnode->textContent) . "\n";
}
echo "</pre>\n";
?>

Expected result:
----------------
url: /289805
content: » Startseite
url: /289805/content/523612
content: » Schöne Sommerferien
url: /289805/content/488545
content: » Unsere Top-Immobilie des Monats
url: /289805/offers/Habitation/listed/Aktualität/0
content: » Wohnimmobilien
url: /289805/offers/AppartmentRent/listed/Aktualität/0
content:     » Wohnung Miete
url: /289805/offers/AppartmentBuy/listed/Aktualität/0
content:     » Wohnung Kauf
url: /289805/offers/HouseBuy/listed/Aktualität/0
content:     » Haus Kauf
url: /289805/offers/SiteLivingBuy/listed/Aktualität/0
content:     » Wohngrundstücke Kauf
url: /289805/offers/Trade/listed/Aktualität/0
content: » Gewerbeimmobilien
url: /289805/offers/Investment/listed/Aktualität/0
content: » Anlageobjekte
url: /289805/content/16428
content: » Kostenfrei...
url: /289805/content/16431
content: » Aktuelles für Sie
url: /289805/content/16437
content: » Unsere Leistungen
url: /289805/content/487731
content: » Referenzen
url: /289805/content/16421
content: » Kontakt
url: /289805/content/16422
content: » Impressum
url: /289805/content/236930
content: » Interessante Links
url: /289805/offers/Habitation/listed/Aktualität/0
content: 
		Listenansicht
	
url: /289805/offers/Habitation/gallery/Aktualität/0
content: 
		Galerieansicht
	
url: /289805/offers/Habitation/listed/Aktualität/1
content: 2
url: /289805/offers/Habitation/listed/Aktualität/2
content: 3
url: /289805/offers/Habitation/listed/Aktualität/3
content: 4
url: /289805/offers/Habitation/listed/Aktualität/1
content: Nächste Seite
url: /289805/expose/61677760
content: 
url: /289805/expose/61677760
content: Wunderschöne und super helle 3-Zimmer-Dachgeschosswohnung in ruhiger Lage von Rodgau (Wohnung Kauf)
url: /289805/expose/61677760
content: Details
url: /289805/expose/61675958
content: 
url: /289805/expose/61675958
content: Besondere Immobilie für Naturliebhaber, die auf die Vorzüge des "Stadtlebens" nicht verzichten möcht (Haus Kauf)
url: /289805/expose/61675958
content: Details
url: /289805/expose/61647677
content: 
url: /289805/expose/61647677
content: Sehr schöne Dachgeschoss - Wohnung mit großer Dachterrasse in kleiner Wohneinheit (Wohnung Miete)
url: /289805/expose/61647677
content: Details
url: /289805/expose/61586639
content: 
url: /289805/expose/61586639
content: Hier können Sie sich verwirklichen: Grundsanierungsbedürftiges Haus in Toplage (Haus Kauf)
url: /289805/expose/61586639
content: Details
url: /289805/expose/61580675
content: 
url: /289805/expose/61580675
content: Große Neubau-Doppelhaushälfte auf schönem Grundstück in zentraler Lage von Jügesheim (Haus Kauf)
url: /289805/expose/61580675
content: Details
url: /289805/expose/61506416
content: 
url: /289805/expose/61506416
content: Eine prima Eigentumswohnung: 3-Zimmer, Erdgeschoss, Terrasse UND Balkon (Wohnung Kauf)
url: /289805/expose/61506416
content: Details
url: /289805/expose/61494550
content: 
url: /289805/expose/61494550
content: Außergewöhnlich gut: Zentrumsnah und trotzdem mit Blick ins Grüne! 3-Zimmerwohnung in Bierstadt (Wohnung Kauf)
url: /289805/expose/61494550
content: Details
url: /289805/expose/61430456
content: 
url: /289805/expose/61430456
content: Top Investition für Kapitalanleger: 2-Zimmer-Erdgeschosswohnung mit Terrasse in Rodgau (Wohnung Kauf)
url: /289805/expose/61430456
content: Details
url: /289805/expose/61235581
content: 
url: /289805/expose/61235581
content: Charmante und sehr wohnliche 3-Zimmerwohnung im begehrten Obertshausen (Wohnung Kauf)
url: /289805/expose/61235581
content: Details
url: /289805/expose/61304802
content: 
url: /289805/expose/61304802
content: 3-Zimmer-Erdgeschosswohnung mit Terrasse !!! FÜR KAPITALANLEGER !!! (Wohnung Kauf)
url: /289805/expose/61304802
content: Details
url: /289805/expose/61417790
content: 
url: /289805/expose/61417790
content: Neu, geräumig, modern, provisionsfrei: Eine Doppelhaushälfte die all Ihre Wünsche erfüllt! (Haus Kauf)
url: /289805/expose/61417790
content: Details
url: /289805/expose/61417776
content: 
url: /289805/expose/61417776
content: Ein traumhafter Garten, eine wunderschöne und moderne Doppelhaushälfte und das alles auch noch provi (Haus Kauf)
url: /289805/expose/61417776
content: Details
url: /289805/expose/61417785
content: 
url: /289805/expose/61417785
content: Provisionsfreie Neubau-Doppelhaus in Mühlheim: Erfüllen Sie sich Ihren Traum vom Eigenheim (Haus Kauf)
url: /289805/expose/61417785
content: Details
url: /289805/expose/61075707
content: 
url: /289805/expose/61075707
content: Ein Wohntraum direkt am Main !!! (Wohnung Kauf)
url: /289805/expose/61075707
content: Details
url: /289805/expose/61348638
content: 
url: /289805/expose/61348638
content: Helle 3-Zimmerwohnung mit Sonnenbalkon in ruhiger Lage (Wohnung Miete)
url: /289805/expose/61348638
content: Details
url: /289805/offers/Habitation/listed/Aktualität/1
content: 2
url: /289805/offers/Habitation/listed/Aktualität/2
content: 3
url: /289805/offers/Habitation/listed/Aktualität/3
content: 4
url: /289805/offers/Habitation/listed/Aktualität/1
content: Nächste Seite
url: /289805/content/16422
content: Impressum
url: http://www.immobilienscout24.de
content: ImmobilienScout24



Actual result:
--------------
url: http://www.immobilienscout24.de
content: 
			
url: http://www.immobilienscout24.de
content: www.immobilienscout24.de
url: mailto:webmaster@immobilienscout24.de
content: webmaster@immobilienscout24.de
url: #
content: 
						



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-02 16:21 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2013-12-02 16:21 UTC] mike@php.net
Yeah, well, I cannot reproduce it either.

If you get a stable reproduce case please post that here and change the status back to "Open".
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC