#39505 [NEW]: xpath query failed if root element has xmlns attribute

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #39505 [NEW]: xpath query failed if root element has xmlns attribute

    From: sghnqk at gmail dot com
    Operating system: linux
    PHP version: 5.2.0
    PHP Bug Type: DOM XML related
    Bug description: xpath query failed if root element has xmlns attribute

    Description:
    ------------
    according to [url]http://www.w3.org/TR/REC-xml-names/[/url] ,
    both
    <root xmlns="...">
    and
    <root xmlns:ns="...">
    are valid,

    xpath->query() will fail with the first case.


    Reproduce code:
    ---------------
    <?php
    $xml=<<<end
    <?xml version="1.0"?>
    <root xmlns="urn:schemas-upnp-org:device-1-0">
    <child />
    </root>
    end;

    $doc=new DomDocument();
    $doc->loadXML($xml);

    $xpath=new DomXpath($doc);

    $query='/root';

    $result=$xpath->query($query);
    echo $result->length;


    Expected result:
    ----------------
    string '1'

    Actual result:
    --------------
    string '0'

    --
    Edit bug report at [url]http://bugs.php.net/?id=39505&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39505&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39505&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39505&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39505&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=39505&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=39505&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39505&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=39505&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=39505&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=39505&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=39505&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=39505&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=39505&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39505&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=39505&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=39505&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39505&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=39505&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39505&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39505&r=mysqlcfg[/url]
    sghnqk at gmail dot com Guest

  2. Similar Questions and Discussions

    1. #38949 [NEW]: Cannot get xmlns value attribute
      From: superruzafa at gmail dot com Operating system: Windows XP PHP version: 5.1.6 PHP Bug Type: DOM XML related Bug...
    2. xmlns attribute
      I am returning xml from a web service. When I look at the response, I notice that the root element has xmlns="". Why is this and how do I correct...
    3. Retrieving XML attribute using XML::XPath::Node::Attribute
      Hi I am trying to retrieve an attribute of a particular node from my XML using "XML::XPath::Node::Attribute", but couldn't come across on how to...
    4. How to specify xpath path to createNode to force element position
      Is it possible to specify a path to createNode that would cause a new element to appear after the first execute but before the queryset element? ...
    5. xpath - how to find a node where a specific attribute does NOT exist?
      Hi, since there doesn't appear to be a way to get the individual elements that make up the xpath to a result node, I'm trying to create an xpath...
  3. #2

    Default #39505 [Opn->Bgs]: xpath query failed if root element has xmlns attribute

    ID: 39505
    Updated by: [email]rrichards@php.net[/email]
    Reported By: sghnqk at gmail dot com
    -Status: Open
    +Status: Bogus
    Bug Type: DOM XML related
    Operating System: linux
    PHP Version: 5.2.0
    New Comment:

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    first case is correct - xpath is namespace aware and root in def ns.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-11-13 19:08:15] sghnqk at gmail dot com

    Description:
    ------------
    according to [url]http://www.w3.org/TR/REC-xml-names/[/url] ,
    both
    <root xmlns="...">
    and
    <root xmlns:ns="...">
    are valid,

    xpath->query() will fail with the first case.


    Reproduce code:
    ---------------
    <?php
    $xml=<<<end
    <?xml version="1.0"?>
    <root xmlns="urn:schemas-upnp-org:device-1-0">
    <child />
    </root>
    end;

    $doc=new DomDocument();
    $doc->loadXML($xml);

    $xpath=new DomXpath($doc);

    $query='/root';

    $result=$xpath->query($query);
    echo $result->length;


    Expected result:
    ----------------
    string '1'

    Actual result:
    --------------
    string '0'


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39505&edit=1[/url]
    rrichards@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139