xpath not working, subscription to mailing lists weirdness

    Date: 04/09/06 (PHP Community)    Keywords: php, html, xml, web, linux, spam, apache

    Hi there.

    I'm trying to load an XHTML file as a DOMDocument, and get its text using xpath to find the node. Something's going wrong somewhere, but I can't figure out what.<br /><br /><a name="cutid1"></a><br />I've used xpath a number of times before, from xslt (Xalan and MSXML2) and C++ (libxml2, Xerces and MSXML2), so I thought I had a good idea of what I was doing. The test case I've got this down to (from reading the PHP docs for <a href="/go.php?http://uk.php.net/manual/en/print/function.dom-domxpath-evaluate.php">DOMXPath->evaluate()</a> and <a href="/go.php?http://uk.php.net/manual/en/print/function.dom-domxpath-query.php">DOMXPath->query()</a> is pretty short.<br /><br />The first file is pretty simple - it's just the data file for the second one to load.<br /><br /><b>page1.php</b><br /><pre> <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <shtml xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Title

    Body



    The second is the one that does the work.

    page2.php
    
    
    
    
    Home page.
    
    
    query($path, $context);
    
            $obj = new ReflectionObject($list);
            print("

    Search from \"" . $context->nodeName . "\" for \"" . $path . "\" (" . $obj->getName() . ")

    \n"); print("
      \n"); for ($i = 0; $i < $list->length; ++$i) { print("
    • " . $list->item($i)->nodeName . "
    • \n"); } print("
    \n"); } $dom = new DOMDocument(); $dom->load("page1.php"); print("

    Document Element node name: " . $dom->documentElement->nodeName . "

    \n"); pathsearch($dom, $dom, "/html/head/title"); pathsearch($dom, $dom, "/"); pathsearch($dom, $dom->documentElement, "/"); pathsearch($dom, $dom, "/*"); pathsearch($dom, $dom, "/html"); pathsearch($dom, $dom, "//html"); pathsearch($dom, $dom->documentElement, "."); pathsearch($dom, $dom->documentElement, "./*"); pathsearch($dom, $dom->documentElement, "./head"); pathsearch($dom, $dom->documentElement, ".//head"); pathsearch($dom, $dom->documentElement, ".//head/*"); pathsearch($dom, $dom->documentElement, ".//head/title"); pathsearch($dom, $dom->documentElement, ".//head//title"); ?>


    I get an empty nodelist for the first pathsearch(), which is the one I'm looking for.

    The second and third calls to pathsearch() check that I can actually access the root node, and get a non-empty list, as expected.

    Call 4 ("/*") finds "html", but 5 and 6 ("/html" and "//html") find nothing. An empty result for "//html" is very odd, considering "/*" finds an "html" node.

    Calls 7-13 try finding other nodes starting from the documentElement() (/html) just in case it doesn't like calling without a context. Of these, only 7 and 8 ("." and "./*") succeed with non-empty results. However the results I get are exactly what I'd expect ("html" and {"head", "body"} respectively) which leaves me even more confused as to why all the others are failing.

    Any help here would be appreciated. Even just reproducing my results would be good, so I know it's not just my setup that's b0rked.

    (I'm running php 5.1.2 with libxml 2.6.23 on apache 2.0.55 on linux 2.6.15. More system info can be provided if necessary)


    I originally tried to subscribe to the php-general mailing list to ask this question there, but haven't been able to, and have had no reply from php-list-admin@lists.php.net or postmaster@lists.php.net.


    I've sent a couple of requests, both from the website and via email, to subscribe to php-general@lists.php.net. Each time I've got the "confirm subscribe to php-general@lists.php.net" reply and replied to it. Each time, I've replied using both of the methods they suggest, but have received nothing since. No "welcome to the list" message, no list messages, no bounces, nothing. I've checked by spam folder, and it's not getting filed there.

    So, I tried emailing php-list-admin@lists.php.net which is supposedly staffed by people. I did that on March 31 and again on April 4. Nothing. No replies, no bounces, nothing.

    So, on April 7 I tried emailing postmaster@lists.php.net. Again nothing.

    Does anyone know WTF is going on over there? Why the hell don't they answer their goddamn email? I've been polite, and I've asked just for some kind of reply to let me know that someone is at least reading my messages. Even a "We're not going to help you" would be more useful that goddamn silence.

    So, does anyone else know if they are just a bunch of useless fucktards, or what?

    Source: http://community.livejournal.com/php/436121.html

« Whats wrong with this... || PHP works in a .PHP file... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home