954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

parsing xml

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"?>
hari2267hari2078hari2188

hmhb.in
Newbie Poster
5 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

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?>
                    Age: <?php echo $record->age?>                   
                    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

DanielTulp
Newbie Poster
10 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: