English 中文(简体)
简单明了 致命错误: 按第136行和在第156条评注中要求成员履行非目标的职能
原标题:simplexml gives Fatal error: Call to a member function attributes() on a non-object in line 136 and when commented out line 156
  • 时间:2012-05-15 20:41:22
  •  标签:
  • php
  • xml
  • svg

with my code I am trying to grab the path data from a xml (used to be svg) file and while I am able to successfully print out the data by the $attributes array, using echo it still pulls up the "call to a member function attributes() on a non-object in (line 136 and 156) I simply don t see what is wrong with the code, although worst case scenario I can always use a hack around that inserts the selected data into a db within the while loop and upon iteration forward to the desired page... I am wondering what exactly is wrong with my code. it echos out the correct information with the echo commands. it just still gives the call to a member function on a non object error

while($number_of_array_path >=1)
{
//declares attributes based on path number for sodipodi attributes line136
$attributes = $xml_file_open->g->path[$path_incremental_counter]-
>attributes( sodipodi , true); 

//sets each attribute within an array and uses the path incremental counter for 
//that pourpose.
$type_array[$path_incremental_counter] = $attributes[ type ];
$cx_array[$path_incremental_counter] = $attributes[ cx ];
$cy_array[$path_incremental_counter] = $attributes[ cy ];
$rx_array[$path_incremental_counter] = $attributes[ rx ];
$ry_array[$path_incremental_counter] = $attributes[ ry ];
echo $type_array[$path_incremental_counter];
echo "<br/>";                               
echo $cx_array[$path_incremental_counter];
echo "<br/>";                               
echo $cy_array[$path_incremental_counter];
echo "<br/>";
echo $rx_array[$path_incremental_counter];
echo "<br/>";
echo $ry_array[$path_incremental_counter];
echo "<br/>";                               


//same as above but for non"sodipodi" attributes. line 156
$attributes = $xml_file_open->g->path[$path_incremental_counter]->attributes();
// echo $attributes[ id ];  
$style_array[$path_incremental_counter] = $attributes[ style ];
$id_array[$path_incremental_counter] = $attributes[ id ];
$d_array[$path_incremental_counter] = $attributes[ d ];
echo $style_array[$path_incremental_counter];
echo "<br/>";
echo $id_array[$path_incremental_counter];
echo "<br/>";
echo $d_array[$path_incremental_counter];
echo "<br/>";



//increments path incremental counter
$path_incremental_counter = $path_incremental_counter + 1;
//decrements number of array path
$number_of_array_path = $number_of_array_path;                                                              
}
最佳回答
foreach($xml_file_open->g->path[$shape_path_iteration_counter]->attributes() 
as $attribute => $value)

非《公约》组成部分

foreach($xml_file_open->g->path[$shape_path_iteration_counter]->
attributes( sodipodi , true) as $attribute => $value)

页: 1

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签