php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14340 DOMXML is broken
Submitted: 2001-12-04 11:55 UTC Modified: 2001-12-05 06:10 UTC
From: deftris at netcourrier dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4.1.0 OS: Linux Debian Woody
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: deftris at netcourrier dot com
New email:
PHP Version: OS:

 

 [2001-12-04 11:55 UTC] deftris at netcourrier dot com
VERSIONS:
PHP4.1RC1/libxml2 v2.4.8
PHP4.099/libxml2 v2.4.8

DESCRIPTION:
some methods seems to be not implemented:
$node->name doesn't work!it gives no output, no crash.

CONFIG OPTS:
 '../configure' '--prefix=/usr' '--with-apxs=/usr/bin/apxs' '--with-regex=system' '--with-config-file-path=/etc/php4/apache' '--disable-rpath' '--disable-debug' '--enable-memory-limit' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-db2' '--with-iconv' '--with-ndbm' '--enable-exif' '--enable-filepro' '--enable-ftp' '--with-gettext' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-pcre-regex=/usr' '--enable-shmop' '--enable-sockets' '--enable-wddx' '--with-xml=/usr' '--with-expat-dir=/usr' '--enable-yp' '--with-zlib' '--without-pgsql' '--disable-static' '--with-layout=GNU' '--with-curl=shared,/usr' '--with-dom=shared,/usr' '--with-zlib-dir=/usr' '--with-gd=shared,/usr' '--with-jpeg-dir=shared,/usr' '--with-xpm-dir=shared,/usr/X11R6' '--with-png-dir=shared,/usr' '--with-freetype-dir=shared,/usr' '--with-imap=shared,/usr' '--with-ldap=shared,/usr' '--with-mcal=shared,/usr' '--with-mhash=shared,/usr' '--with-mm' '--with-mysql=shared,/usr' '--with-recode=shared,/usr' '--with-sablot=shared,/usr' '--with-snmp=shared' '--with-sybase-ct=shared,/usr' '--with-ttf=shared,/usr' '--with-t1lib=shared,/usr'
This is a relatively standart install from Debian Woody packages.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-04 13:05 UTC] mfischer@php.net
A sample script would help very much.

I think what you are searching for is actually 'tagname'.

If you're unsure, just try a 

 print_r($domobjnode);

and see its properties.

Feedback.
 [2001-12-04 13:06 UTC] mfischer@php.net
Wtf? Sorry, feedback.
 [2001-12-04 15:23 UTC] deftris at netcourrier dot com
print_r($xmlstring) works well, tough.
an example code:
_____________________________________________________
<?
$string = "<?xml version=\"1.0\"?>
<webcam_users>
	<user>
		<login>user1</login>
		<password>passwd1</password>
	</user>
	<user>
		<login>user2</login>
		<password>passwd2</password>
	</user>
	<user>
		<login>guest</login>
		<password>guest_passwd</password>
	</user>
</webcam_users>";

$doc = xmldoc($string);
$root = domxml_root($doc);
$users = domxml_children($root);
foreach ($users as $user){
	if ($user->type == "1") {
	$nom = $user-> name;
	print "balise: ".$nom."<BR>";}
	}

function find_content($parent,$name){    
$nodes = $parent->children();
	while($node = array_shift($nodes)) {
	if ($node->name == $name){
		return get_content($node);
			}
		}
?>
_______________________________________________
This code returns:
________________________________________
balise: user
balise: user
balise: user
___________________________________________
with php4.0.6 /libxml2 2.4.5
and nothing with php4.1RC1 / libxml2 2.4.8


 [2001-12-04 15:24 UTC] deftris at netcourrier dot com
and the problem is the same under Debian Sid (unstable) /php4.1RC1 / libxml2 2.4.8
 [2001-12-04 20:58 UTC] mfischer@php.net
As i said, its not 'name' in this case but 'tagname'. This is the behaviour now.

Not a bug, closing.
 [2001-12-05 05:40 UTC] deftris at netcourrier dot com
ok i modified the $node->name in $node->tagname
the script:
--------------------------------------------
<?
$string = "<?xml version=\"1.0\"?>
<webcam_users>
	<user>
		<login>user1</login>
		<password>passwd1</password>
	</user>
	<user>
		<login>user2</login>
		<password>passwd2</password>
	</user>
	<user>
		<login>guest</login>
		<password>guest_passwd</password>
	</user>
</webcam_users>";

$doc = xmldoc($string);
$root = domxml_root($doc);
$users = domxml_children($root);
foreach ($users as $user){
	if ($user->type == "1") {
	$nom = $user->tagname;
	print "balise: ".$nom."<BR>";
	print_r($user);}
	}

function find_content($parent,$name){    
$nodes = $parent->children();
	while($node = array_shift($nodes)) {
	if ($node->tagname == $name){
		return get_content($node);
			}
		}
	return ""; 
}
?>
--------------------------------------------------
the result with PHP4.1RC1 /libxml2 v2.4.8: NOTHING!
--------------------------------------------------
with PHP4.0.6 / libxml2 v2.4.5:

balise:
DomNode Object ( [name] => user [content] => user1 passwd1 [node] => Resource id #4 [type] => 1 ) balise:
DomNode Object ( [name] => user [content] => user2 passwd2 [node] => Resource id #6 [type] => 1 ) balise:
DomNode Object ( [name] => user [content] => guest guest_passwd [node] => Resource id #8 [type] = > 1 )
--------------------------------------------------
Before trying DOMXML, i downloaded latest PHP manual ...
but ... help me I'm lost I don't underdstand...

as you say $node->tagname should work ... if so, why do I have no output ???

If it's not a bug, what is the correct syntax? Please can you correct my script? (sorry, I'm aware that I make you loose your time)
Thanks a lot!

 [2001-12-05 06:10 UTC] mfischer@php.net
Well, you're using domxml_children() which is broken in the release branch if you call it as a function. It's fixed in CVS but still those fixes need testing and therefore won't be in the next release (4.1.0).

Use $root->children() instead.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 14:01:31 2024 UTC