i have the following xml file.how to display the first tag (tag by tag) then when next button are click the second tag is display


<?xml version="1.0"?>
<records>
<reg >
<name>hari</name>
<age>22</age>
<mark>67</mark>

</reg>
</records>
<records>
<reg >
<name>hari</name>
<age>20</age>
<mark>78</mark>

</reg>
</reg>
<reg>
<book >
<name>hari</name>
<age>21</age>
<mark>88</mark>

</reg>
</records>

to display data from an xml check out these resources
http://www.w3schools.com/PHP/php_xml_simplexml.asp
http://php.net/manual/en/book.xml.php

here is some sample code I use to display text (used on http://photo.danieltulp.nl)

<?php
                $newsitems = new SimpleXMLElement('xmlfilename.xml', null, true);

                foreach ($newsitems as $item):?>
                <div class="newsitem">
                    <h4><?php echo $item->title?><span class="date"><?php echo $item->date?></span></h4>                    
                    <p><?php echo $item->body?></p>
                </div>
                <?php 
                endforeach;?>

if you want a button to go the next record, you could use:

<?php
                $records = new SimpleXMLElement('records.xml', null, true);
                $i = 0;
                foreach ($records as $record):?>
                <div class="record-<?php echo $i;?>" style="display:none;">
                    <p>Name: <?php echo $record->name?><br />
                    Age: <?php echo $record->age?><br />                   
                    Mark: <?php echo $record->mark?></p>
                </div>
                $i = $i + 1;
                <?php endforeach;?>

and then use javascript to set the display property to block or inline

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.