Jump to content

PHP XML Parser with Array


ndesign.ie

Recommended Posts

Ok this is little hard to grasp.

What i have is a PHP page, first parsing the XML into an array and adding textfield and button to each entry.

Problem is calling the function.  :wtf: I know how to but can't really grasp how to go about it.

 

Code:

<some parsing code>

 

if(isset($_POST['SAVE_ME'])) {

SAVE_ME();

}

foreach($arfiles as $arFile)

{

 

$insXmlParser= new clsXmlParser($arFile);

if($aArray=$insXmlParser->Parse())

echo LIST_CONTENTS($aArray);    }

 

 

function LIST_CONTENTS($arrayname,$tab="&nbsp&nbsp&nbsp&nbsp ",$indent=0)

{

 

$retval=$currenttab="";

 

 

while(list($key, $value) = each($arrayname))

{

for($i=0; $i<$indent; $i++) $currenttab .= $tab;

if (is_array($value))

{

$retval .= "<form action='<?=$_SERVER['PHP_SELF'];?>' method='post'>";

$retval .= "Element $value $currenttab$key $currenttab  <input type=button name='$value$itemhht' value='UpDate $value$itemhht' onClick='SAVE_ME''></BR>$currenttab</BR>";

$retval .= LIST_CONTENTS($value,$tab,$indent+1)."$currenttab</BR>";

$retval .= "</form>";

 

}

else $retval .= "$currenttab$key => <textarea name='$key$itemhht' id='$key$itemhht' cols=60 rows=1 value='$value'>${value}</textarea></BR>";

 

$currenttab = NULL;

$itemhht++;

}

 

return $retval;

}

 

function SAVE_ME($arrayname,$indent=0) //this is the function needed to be run

{

for($i=0; $i<Count($aArray); $i++);

if ($aArray[$i] == $_GET['$value$itemhht'])

{

echo $_GET['$value$itemhht'];

}

else

    echo $aArray[$i];

}

 

 

any help/info/comments appreciated

Link to comment
https://forums.phpfreaks.com/topic/197026-php-xml-parser-with-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.