[PHP]My XML stuff

Status
Not open for further replies.

Adil

DevBest CEO
May 28, 2011
1,276
714
kso basically, I was reading up on a tutorial, and I created this little xml parser.
PHP:
<?php
$url = 'clientmsg.xml';
$xml = simplexml_load_file($url);
//get stuff now
$title=$xml->header[0]->title;
$body=$xml->header[0]->body;
$footer=$xml->header[0]->footer;
echo $title . " " .  $body . " " .$footer;
?>
All is good and well. However, there is one major flaw, which is the array. The array value (header[0]) would need to be changed manually, every time I want to parse a new header. Is there any way of doing this automatically?
 

Adil

DevBest CEO
May 28, 2011
1,276
714
My XML file
HTML:
<?xml version="1.0"?>
<client>
<header>
<title>@@</title>
<body>hi</body>
<footer>aaa</footer>
</header>
<header>
<title>@A</title>
<body>hi</body>
<footer>aduojefkf</body>
<footer>adil</footer>
</header>
</client>
 
Status
Not open for further replies.

Users who are viewing this thread

Top