|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14545 DOM seems not to work
Submitted: 2001-12-16 05:55 UTC Modified: 2001-12-16 07:20 UTC
From: alex at rsd dot it Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 4.1.0 OS: RedHat 7.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: alex at rsd dot it
New email:
PHP Version: OS:


 [2001-12-16 05:55 UTC] alex at rsd dot it
the following code (taken from phpbuilder) works with php.4.0.6 
with dom and fails with php 4.1.0


# make an example xml document to play with
$xmlstr = "<" . "?" . "xml version=\"1.0\"" . "?" . ">";
$xmlstr .=
    <position type=\"contract\">Web Guy</position>

# load xml data ($doc becomes an instance of 
# the DomDocument object)
$doc = xmldoc($xmlstr);

# get root node "employee"
$employee = $doc->root();

# get employee's children ("name","position")
$nodes = $employee->children();

# let's play with the "position" node
# so we must iterate through employee's
# children in search of it
while ($node = array_shift($nodes))
    if ($node->name == "position")
        $position = $node;

# get position's type attribute
$type = $position->getattr("type");

# get the text enclosed by the position tag
# shift the first element off of position's children
$text_node = array_shift($position->children());

# access the content property of the text node
$text = $text_node->content;

# echo out the position and type
echo "position: $text<BR>";
echo "type: $type";



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-16 07:20 UTC]
This extension has changed quite a lot since 4.0.6 (its DOM2 conform now).

To get a overview how the new tree looks like use

  $tree = xmltree($xmlstr);

There is no bug (yet ;), Bogusifying.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jun 21 19:01:26 2021 UTC