Voting

: min(six, five)?
(Example: nine)

The Note You're Voting On

info at evasion dot cc
19 years ago
Suppose you have loaded a XML file into $simpleXML_obj.
The structure is like below :

SimpleXMLElement Object
(

[node1] => SimpleXMLElement Object
(
[subnode1] => value1
[subnode2] => value2
[subnode3] => value3
)

[node2] => SimpleXMLElement Object
(
[subnode4] => value4
[subnode5] => value5
[subnode6] => value6
)

)

When searching a specific node in the object, you may use this function :

<?php

function &getXMLnode($object, $param) {
foreach(
$object as $key => $value) {
if(isset(
$object->$key->$param)) {
return
$object->$key->$param;
}
if(
is_object($object->$key)&&!empty($object->$key)) {
$new_obj = $object->$key;
$ret = getCfgParam($new_obj, $param);
}
}
if(
$ret) return (string) $ret;
return
false;
}
?>

So if you want to get subnode4 value you may use this function like this :

<?php
$result
= getXMLnode($simpleXML_obj, 'subnode4');
echo
$result;
?>

It display "value4"

<< Back to user notes page

To Top