php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15257 Can't retrieve node content
Submitted: 2002-01-28 14:13 UTC Modified: 2002-01-29 04:30 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: work at gullidge dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4.1.1 OS: Windows2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: work at gullidge dot com
New email:
PHP Version: OS:

 

 [2002-01-28 14:13 UTC] work at gullidge dot com
Sorry in advance if this isn't considered a bug.

The DomXML content property is no longer available in 4.1.1 as we now are referencing elements instead of nodes, but I can't see a way of extracting the content of the element/node.

Following works in 4.06:

$docnode = xmldoc($xmlString);
$rootNode = $docnode->root();
$nodes = $rootNode->children();

for ($nodeNumber = 0; $nodeNumber < count($nodes); $nodeNumber++) {
  $nodeName = $nodes[$nodeNumber]->name;

  // ... some more nodeName comparisons here				
  if ($nodeName == "redirect") {
    $redirectURL = $nodes[$nodeNumber]->content;
  }
}

In 4.1.1 tagname replaces name, but I can't see anything that replaces or gives me a reference to content.

Again, sorry if this isn't considered a bug.  I've only been coding PHP for 2 days and I'm still finding my way around.

PS. I could do with using 4.1.1 as 4.0.6 doesn't allow https in curl

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-28 14:31 UTC] jtate at mi-corporation dot NOSPAM dot com
Try replacing your $nodes[$nodeNumber]->content line with 
$redirectURL = getContent($nodes[$nodeNumber]);

Where getContent is:
function getContent ($n)
{
    if (!($children = $n->children())) return '';

    $content = '';
    foreach ($children as $c) {
        if ($c->type == XML_TEXT_NODE) {
            $content .= $c->content;
        }
    }

    return $content;
}

I can verify the behavior.  I'm thinking it is a bug too.  If functionality has been changed, a change in documentation is in order.
 [2002-01-29 03:38 UTC] work at gullidge dot com
Thank you sir,

  That works a treat.
 [2002-01-29 04:30 UTC] chregu@php.net
this will be implemented in the next version of php (4.2) or already in cvs now with

$node->get_content()


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 15:01:27 2025 UTC