PHP Classes

$var->ignore_level

Recommend this page to a friend!

      SimpleXML for PHP4  >  All threads  >  $var->ignore_level  >  (Un) Subscribe thread alerts  
Subject:$var->ignore_level
Summary:Am I setting this wrong?
Messages:7
Author:Elvis McNeely
Date:2008-05-24 04:03:13
Update:2008-05-28 12:06:08
 

  1. $var->ignore_level   Reply   Report abuse  
Picture of Elvis McNeely Elvis McNeely - 2008-05-24 04:03:13
If I understand your howto.txt doc you can go skip/forward into the object/array with $var->ignore_level. I am not getting any changes with this:

<?
require_once "simplexml.class.php";

//if you want to use it as a function;

if(!function_exists("simplexml_load_file")){
function simplexml_load_file($file){
$sx = new simplexml;
$var->ignore_level = 2; // is this set wrong?
// $sx->ignore_level = 2; // doesn't work eigher
return $sx->xml_load_file($file);
}
}

$file = "xml.xml";
$data = simplexml_load_file($file);

print '<pre>';
print_r($data);

?>

  2. Re: $var->ignore_level   Reply   Report abuse  
Picture of Taha Paksu Taha Paksu - 2008-05-24 12:26:13 - In reply to message 1 from Elvis McNeely
"$sx->ignore_level = 2;" should work. Try setting different values and test them. And to clarify, this setting is used to change the dom container item level.

  3. Re: $var->ignore_level   Reply   Report abuse  
Picture of Elvis McNeely Elvis McNeely - 2008-05-25 07:28:26 - In reply to message 2 from Taha Paksu
Under PHP5 this feature is not working. I changed the var from within the class and no changes were made.

  4. Re: $var->ignore_level   Reply   Report abuse  
Picture of Elvis McNeely Elvis McNeely - 2008-05-27 22:24:44 - In reply to message 2 from Taha Paksu
Have you had a chance to test this? Just checking in...

  5. Re: $var->ignore_level   Reply   Report abuse  
Picture of Taha Paksu Taha Paksu - 2008-05-28 06:50:41 - In reply to message 4 from Elvis McNeely
yes i tested it with this code and that works either in php4 or php5. the code i have tested with is :

require "simplexml.class.php";
$sx = new simplexml;
$sx->ignore_level=1;
$feed = $sx->xml_load_file("artstil.xml");
echo "<pre>";
print_r($feed);
echo "</pre>";

you can change the ignore level and see the changes.

Maybe you are setting this var after you parse the xml file. That won't work. You should set the ignore_level var first and then get the xml file.

  6. Re: $var->ignore_level   Reply   Report abuse  
Picture of Elvis McNeely Elvis McNeely - 2008-05-28 10:00:14 - In reply to message 5 from Taha Paksu
Yes, I got it working earlier. I must of had something wrong to start with. Thanks for the reply though to confirm it works in PHP 4 and 5.

Is the $var->ignore_level is limited? I was hoping to jump from 1-5 levels, as needed, if possible.

  7. Re: $var->ignore_level   Reply   Report abuse  
Picture of Taha Paksu Taha Paksu - 2008-05-28 12:06:08 - In reply to message 6 from Elvis McNeely
The only limit is the xml child depth.If you set a level bigger than it, the result becomes empty.