php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10994 DOMXML CDATA Node Bug
Submitted: 2001-05-21 13:49 UTC Modified: 2002-06-03 18:19 UTC
From: dennis at svitonline dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4.0.5 OS: Winnt
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: dennis at svitonline dot com
New email:
PHP Version: OS:

 

 [2001-05-21 13:49 UTC] dennis at svitonline dot com
Hello Dear PHP Support.
I have compatability problem with PHP 4.04 - PHP 4.05, exactly in DOMXML (i mean) module.

This is piece of my code:

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

<?

	function XML_Def_Parse($xml_file) {

	  $doc = xmldoc(join("", file($xml_file)) );  
	  $ctx = xpath_new_context($doc );  
	
	  //
	
	
	  $doc_vars = xml_parse_vars($ctx, "//DOC/VAR");  	
	        
	  $obj = xpath_eval($ctx, "//DOC/BLOCKS/BLOCK");
	  $arr = $obj->nodeset;
	    
	  
	    for($block_n=1; $block_n<sizeof($arr)+1; ++$block_n) {
	            
	  	$block_vars = xml_parse_vars($ctx, "//DOC/BLOCKS/BLOCK[$block_n]/VAR");
		  	  	  	
	  	
	  
	  	  	
	   	
	  	$obj2 = xpath_eval($ctx, "//DOC/BLOCKS/BLOCK[$block_n]/BLOCKSET");
	 	$arr2 = $obj2->nodeset; 
	  	
			
			for($blockset_n=1; $blockset_n<sizeof($arr2)+1; ++$blockset_n) {
			
			$myobj = xpath_eval($ctx, "//DOC/BLOCKS/BLOCK[$block_n]/BLOCKSET[$blockset_n]");		
			$myarr = $myobj->nodeset;
			
			$blockset_type = $myarr[0]->getattr("type");
							
			//						
					
			$obj3 = xpath_eval($ctx, "//DOC/BLOCKS/BLOCK[$block_n]/BLOCKSET[$blockset_n]/BLOCKSETELEMENT");
			$arr3 = $obj3->nodeset; 
	  	
	  			$blocksetelements = array();
	  	
	  			for($blocksetelement_n=1; $blocksetelement_n<sizeof($arr3)+1; ++$blocksetelement_n) {
	  				  	  				  	
	  					$blocksetelement_vars = xml_parse_vars($ctx, "//DOC/BLOCKS/BLOCK[$block_n]/BLOCKSET[$blockset_n]/BLOCKSETELEMENT[$blocksetelement_n]/VAR");
				  				  		
						$blocksetelements[] = $blocksetelement_vars;
		  				
				}
			
			
			//$blocksets[$blockset_type] = array(array("sa"=>"as"),array("s2"=>"a2"));
			
			$blocksets[$blockset_type] = $blocksetelements;
				
			}
	  			
	  	
	
		
	  	$blocks[] = array_merge($block_vars, $blocksets);
	
	 	}		



	$blocks_arr = array("BLOCKS"=>$blocks);
	$doc_v = array_merge($doc_vars, $blocks_arr);
			
	}
	

	
	
	function xml_parse_vars($ctx,$path) {

	  $obj = xpath_eval($ctx, $path);
	  $arr = $obj->nodeset;

	  if($path == "//DOC/BLOCKS/BLOCK[1]/BLOCKSET[2]/BLOCKSETELEMENT[1]/VAR") {
	  print_r($arr);
	  }
	      
	  	for($x=0; $x<sizeof($arr); ++$x) {
	
			$name  = $arr[$x]->getattr("name");
			$value = $arr[$x]->content;
	              
	                $results[$name] = $value;
	                  		
	  		}
	     	
	  return $results;
	  		
	 } //function


XML_Def_Parse("kulichki.xml");

?>

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

This is "kulichki.xml":

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


<?xml version="1.0"?>

<DOC version="1.0" copyright="(c) Denis Torbichuk, 2000">
	
	<VAR name="DOC_CODE">KULICHKI.TV</VAR>
	<VAR name="DOC_DESC">????????? ??????????? ?? Kulichki</VAR>
	<VAR name="DOC_URL">tv6.htm</VAR>
	
	
	<BLOCKS>	
		
	  <BLOCK number="1">
		
		<VAR name="BLOCK_DESC">????? ????</VAR>
		<VAR name="BLOCK_BEGIN"></VAR>
		<VAR name="BLOCK_END"></VAR>
		
			
			<BLOCKSET type="SINGLE">
			</BLOCKSET>
		
		
			<BLOCKSET type="MULTIPLE">
			
				<BLOCKSETELEMENT>

<!--
<P><FONT SIZE=+2><B>???????????. 09 ??????. 41 ?????<br></B></FONT><HR>
-->
				
				<VAR name="EL_DESC">?????/????</VAR>
	
				<VAR name="EL_PATTERN_BEGIN"/>
				<VAR name="EL_PATTERN"><![CDATA[<P>.*?<FONT.*?><B>{%%:day}. {%%:day} {%%:month}. {%%:channel}<br>.*?<HR>.*?<pre>{%%:programs}</pre>]]></VAR>
				<VAR name="EL_PATTERN_END"/>
				
				</BLOCKSETELEMENT>
												
			
			</BLOCKSET>		
		
		
		</BLOCK>
	
	
	
	
	
	</BLOCKS>



</DOC>

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


This script output in PHP 4.04 (it is right):

X-Powered-By: PHP/4.0.4
Content-type: text/html

Array
(
    [0] => DomNode Object
        (
            [type] => 1
            [name] => VAR
            [content] => ?????/????
            [node] => Resource id #24
        )

    [1] => DomNode Object
        (
            [type] => 1
            [name] => VAR
            [node] => Resource id #25
        )

    [2] => DomNode Object
        (
            [type] => 1
            [name] => VAR
            [content] => <P>.*?<FONT.*?><B>{%%:day}. {%%:day} {%%:month}. {%%:channel}<br>.*?<HR>.*?<pre>{%%:programs}</pre>
            [node] => Resource id #26
        )

    [3] => DomNode Object
        (
            [type] => 1
            [name] => VAR
            [node] => Resource id #27
        )

)


But this is output from PHP 4.05 (it is wrong):

X-Powered-By: PHP/4.0.5
Content-type: text/html

Array
(
    [0] => DomNode Object
        (
            [type] => 1
            [name] => VAR
            [content] => ?????/????
            [node] => Resource id #24
        )

    [1] => DomNode Object
        (
            [type] => 1
            [name] => VAR
            [content] => 
            [node] => Resource id #25
        )

    [2] => DomNode Object
        (
            [type] => 1
            [name] => VAR
            [content] => 
            [node] => Resource id #26
        )

    [3] => DomNode Object
        (
            [type] => 1
            [name] => VAR
            [content] => 
            [node] => Resource id #27
        )

)

-----

As you see my CDATA node content is empty in PHP 4.05 case.
Why? It is bug?
When I insert text in node instead CDATA it is works.
Can you explain me problem?

P.S. I'm using PHP 4.04 & PHP 4.05 on WinNT (W2k) platform.

Thanks.

Sincerely yours,
Denis Torbichuk.
dennis@svitonline.com

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-22 03:36 UTC] mfischer@php.net
Can you try with latest RC and see if it works

http://www.php.net/~zeev/php-4.1.0RC3.tar.gz

Feedback.

 [2001-11-30 21:00 UTC] mfischer@php.net
Update: Fix is coming, assigned to me.

Btw, the syntax has changed since then, you'll have to use:

  print_r($arr[2]->children());

to see your CDATA node then.

 [2001-12-01 14:46 UTC] mfischer@php.net
Should be fixed in CVS. Closing.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Apr 02 10:01:23 2020 UTC