php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68267 Analysis of the problem
Submitted: 2014-10-20 07:17 UTC Modified: 2014-10-20 07:26 UTC
From: ian dot email at qq dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 5.6.2 OS: win7/centos
Private report: No CVE-ID: None
 [2014-10-20 07:17 UTC] ian dot email at qq dot com
Description:
------------
<?xml version="1.0" encoding="UTF-8"?>
<web>
	<seo>
		<theme/>
		<keys>keys</keys>
		<title>title</title>
		<desc>desc</desc>
		<banner>banner</banner>
	</seo>
	
	<upload>
		<img>
			<size>1000</size>
			<type>
				bmp,gif,jpg,png,jpeg
			</type>
			<show>
				thumb:60*60|norm:320*320|zoom:512*512
			</show>
		</img>
	</upload>
</web>

$xml = new \DomDocument('1.0', 'UTF-8');
$xml->load('web.xml');
$notes = $xml->getElementsByTagName('img');
for ($index = 0; $index < $notes->length; $index++) {
	foreach ($notes->item($index)->childNodes as $nv){
		if($nv->nodeType == XML_ELEMENT_NODE) 
		echo $nv->nodeName.'=>'.$nv->nodeValue.'<br />';
	}
}

Test script:
---------------
<?xml version="1.0" encoding="UTF-8"?>
<web>
	<seo>
		<theme/>
		<keys>keys</keys>
		<title>title</title>
		<desc>desc</desc>
		<banner>banner</banner>
	</seo>
	
	<upload>
		<img>
			<size>1000</size>
			<type>
				bmp,gif,jpg,png,jpeg
			</type>
			<show>
				thumb:60*60|norm:320*320|zoom:512*512
			</show>
		</img>
	</upload>
</web>

$xml = new \DomDocument('1.0', 'UTF-8');
$xml->load('web.xml');
$notes = $xml->getElementsByTagName('img');
for ($index = 0; $index < $notes->length; $index++) {
	foreach ($notes->item($index)->childNodes as $nv){
		if($nv->nodeType == XML_ELEMENT_NODE) 
		echo $nv->nodeName.'=>'.$nv->nodeValue.'<br />';
	}
}

Expected result:
----------------
$notes = $xml->getElementsByTagName('img');  Cycle number is wrong
$notes = $xml->getElementsByTagName('size');  Results cannot be obtained

Actual result:
--------------
win7:
size=>1000
type=> bmp,gif,jpg,png,jpeg 
show=> thumb:60*60|norm:320*320|zoom:512*512 

centOS:
size=>1000
type=> bmp,gif,jpg,png,jpeg 
show=> thumb:60*60|norm:320*320|zoom:512*512 
size=>1000
type=> bmp,gif,jpg,png,jpeg 
show=> thumb:60*60|norm:320*320|zoom:512*512 
size=>1000
type=> bmp,gif,jpg,png,jpeg 
show=> thumb:60*60|norm:320*320|zoom:512*512 
size=>1000
type=> bmp,gif,jpg,png,jpeg 
show=> thumb:60*60|norm:320*320|zoom:512*512 
size=>1000
type=> bmp,gif,jpg,png,jpeg 
show=> thumb:60*60|norm:320*320|zoom:512*512 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-20 07:26 UTC] ian dot email at qq dot com
-Status: Open +Status: Closed
 [2014-10-20 07:26 UTC] ian dot email at qq dot com
Operation problems
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC