473,395 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How can get RANDOM record from XML file?

****************************************
How can get RANDOM record from XML file?
****************************************
for e.g. in xml files i have aprox.200 records.
how get random position and display that in html.
My Xml (and english) i'ts very poor.
Help..... maybe some solution or example.
Thanks !
****************************************
Jul 20 '05 #1
6 10614


Diodak wrote:
****************************************
How can get RANDOM record from XML file?
****************************************
for e.g. in xml files i have aprox.200 records.
how get random position and display that in html.
My Xml (and english) i'ts very poor.
Help..... maybe some solution or example.


If you are using XSLT you could use the random extension from
http://www.exslt.org/random/function...nce/index.html to
generate a random number and then index some elements as needed.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
See:
"Casting the Dice with FXSL: Random Number Generation Functions in XSLT"
at:

http://fxsl.sourceforge.net/articles...20FXSL-htm.htm

This is pure XSLT 1.0 (and also 2.0) code.
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:40******@olaf.komtel.net...


Diodak wrote:
****************************************
How can get RANDOM record from XML file?
****************************************
for e.g. in xml files i have aprox.200 records.
how get random position and display that in html.
My Xml (and english) i'ts very poor.
Help..... maybe some solution or example.


If you are using XSLT you could use the random extension from
http://www.exslt.org/random/function...nce/index.html to
generate a random number and then index some elements as needed.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3
Thank's but this solution not exacly what i want.
I want display only one from recordcount and that one mast be
integer and random. Maybe my english is to poor to explain that.
//part of xml file
<galeria>
<foto>
<min>1m.jpg</min>
<max>1.jpg</max>
<data>2004.04.04</data>
<autor>Marcin</autor>
<kat>Przyroda</kat>
</foto>
<foto>
<min>2m.jpg</min>
<max>2.jpg</max>
<data>2004.03.08</data>
<autor>Anna</autor>
<kat>Krajobraz</kat>
</foto>
.............
</galeria>
I want display random node 'foto'

How i can do that?
Please give me hint or part of source xsl file

Best Regards!

__________________________________________________
Użytkownik "Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> napisał w
wiadomo¶ci news:c5************@ID-152440.news.uni-berlin.de...
See:
"Casting the Dice with FXSL: Random Number Generation Functions in XSLT"
at:

http://fxsl.sourceforge.net/articles...ce%20with%20FX
SL-htm.htm
This is pure XSLT 1.0 (and also 2.0) code.
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:40******@olaf.komtel.net...


Diodak wrote:
****************************************
How can get RANDOM record from XML file?
****************************************
for e.g. in xml files i have aprox.200 records.
how get random position and display that in html.
My Xml (and english) i'ts very poor.
Help..... maybe some solution or example.


If you are using XSLT you could use the random extension from
http://www.exslt.org/random/function...nce/index.html to
generate a random number and then index some elements as needed.
--

Martin Honnen
http://JavaScript.FAQTs.com/


Jul 20 '05 #4

"Diodak" <di*****@poczta.onet.pl> wrote in message
news:c5**********@news.onet.pl...
Thank's but this solution not exacly what i want.
I want display only one from recordcount and that one mast be
integer and random. Maybe my english is to poor to explain that.
//part of xml file
<galeria>
<foto>
<min>1m.jpg</min>
<max>1.jpg</max>
<data>2004.04.04</data>
<autor>Marcin</autor>
<kat>Przyroda</kat>
</foto>
<foto>
<min>2m.jpg</min>
<max>2.jpg</max>
<data>2004.03.08</data>
<autor>Anna</autor>
<kat>Krajobraz</kat>
</foto>
............
</galeria>
I want display random node 'foto'

How i can do that?
Please give me hint or part of source xsl file


In the quoted article there is an example with source code
(test1-random.xsl) of generating 100 randoms in the range [1, 10].

Use the same code to generate one (or whatever number of randoms you need)
random in the range [1, count(/galeria/foto)]. Let's have this random in a
xsl:variable named $theRand.

Then your random node is:

/galeria/foto[$theRand]
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Jul 20 '05 #5
Thank's again!
MSIE5 don't support: count(/galeria/foto) and if i use Variable same too :(


Jul 20 '05 #6

"Diodak" <di*****@poczta.onet.pl> wrote in message
news:c5**********@news.onet.pl...
Thank's again!
MSIE5 don't support: count(/galeria/foto) and if i use Variable same too

:(

You were asking an *XSLT* question -- this has little to do with IE5 (a
browser).

IE5 can "support" true XSLT if MSXML3 isinstalled in "replace mode" -- just
search for:
msxml3 replace mode
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Stefanie | last post by:
Hi, I have a question about declaring variables for writing data to a file for random access. I have two string variables declared in a module (user-defined types). The point is that for one of...
2
by: Ini | last post by:
Hi, Is there an easy way to pick at random one record out of a recordset and then leave this recordset? I was thinking about doing a recordcount of the recordset, then find at random the...
2
by: sugaray | last post by:
I want to write a school computer billing system, one of the function is to distribute machine id using rand() for each student log on, suppose there's 100 machines, when each person log on, the...
2
by: Pete via DotNetMonster.com | last post by:
Hi, I need to display a different random record or link each day. I have the random part working so that if the browser is refreshed a new record will display. I'm not sure however how to...
1
by: Steven Smith | last post by:
Hi Guys How do I check whether or not a specific record number in an initialised random access file is empty or not ? What I need to do is when DisplayButton.Click event is triggered the...
21
by: Gary Bond | last post by:
Hi All, I am a bit stuck with a project: Specifically, when making a database like engine in 'the old days', I would have wrapped a record class with a stream class, so I could have a file of...
26
by: Jimmy | last post by:
ill have a database with 1 table and 3 fields: ID FIRSTNAME LASTNAME (the ID field will be the auto incrementing index) there might be 10 records in the DB, there might be 10,000. i...
48
by: Jimmy | last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far: <% Dim oConn, oRS, randNum Randomize() randNum = (CInt(1000 * Rnd) + 1) *...
4
by: knuckels23 | last post by:
Hi All, I have a Random access file which is written using VB 6.0. I need to read this file using C#. The record used in VB to write the Random access file is as follows Type AA aa1 As...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.