Starters I’m developing for V4.0 and up so no simple_XML. Just skip down to see what i want to do. I’ve tried for the last 3 hours and cant figure it out.
//edit, is it possible to get the source for simple_xml and just include it with the file or is that against the licence/use thingy’s.
//Parse Function//
function parse_node($node) {
global $PART;
if ($node->has_child_nodes()) {
foreach($node->child_nodes() as $n) {
if ($n->node_name() == '#text') {
eval("$node->name=\"" . $n->node_value() . "\";");
}
else {
$n->name = $node->name . '->' . $n->node_name();
parse_node($n);
}
}
}
}
//Read File//
$xmlstg = file_get_contents("xtag.xml");
$xmlstg = str_replace("
", "", $xmlstg);
$xmlstg = str_replace(" ", "", $xmlstg);
//Parse File//
$dom = domxml_open_mem($xmlstg,DOMXML_LOAD_PARSING,$error);
$root = $dom->document_element();
$root->name = '$PART';
parse_node($root);
//Get Part//
$value = $PART->parts->part1;
<?xml version="1.0"?>
<PART>
<parts>
<part1>valueiget</part1>
<part2>othervalue</part2>
</parts>
</PART>
** What I want to do with the XML and PHP.**
//Get Part//
$value = $PART->parts[1]->part1;
<?xml version="1.0"?>
<PART>
<parts>
<part1>othervalue</part1>
<part2>othervalue</part2>
</parts>
<parts>
<part1>valueiget</part1>
<part2>othervalue</part2>
</parts>
</PART>