Dan
Dan

Reputation: 267

Select and echo a random entry from an XML file in php

I am new to XML, please help. I have a small xml file like this...

<?xml version="1.0" encoding="utf-8"?>
<VISITOR> 
    <VID="1">
        <NAME>Irena Lyns</NAME>
        <FROM>Shenfield</FROM>
        <COMMENT>I'm so glad I came.Everything is so beautiful.</COMMENT>
    </VID> 
    <VID="2">
        <NAME>Gabriella</NAME>
        <FROM>ITALIA</FROM>
        <COMMENT>Wonderful!!! </COMMENT>
    </VID>
</VISITOR>

What is the code I would need to display a random VID, NAME, FROM and COMMENT on my php page?

Thank you in advance!!! :)

Upvotes: 0

Views: 1076

Answers (1)

bensiu
bensiu

Reputation: 25584

parse it with SimpleXML and chose random record from result - look at examples

Upvotes: 1

Related Questions