Results 1 to 2 of 2
  1. #1
    matthew.parse is offline Member
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    0

    Default random node from an xml file

    Hello

    I'm a beginner

    how do i parse an xml document, and choose a random node from within it?

    the xml file is as follows

    <root>
    <activity>
    <activity>Running</activity>
    </activity>
    <activity>
    <activity>Swimming</activity>
    </activity>
    <activity>
    <activity>Football</activity>
    </activity>
    <activity>
    <activity>Driving</activity>
    </activity>
    <activity>
    <activity>At Work</activity>
    </activity>
    </root>

    and i would like to be able to go through it, and choose a random node from it

    i have gone all over google looking for similar examples "dom parser java random node" all those key words etc, but i'm stumped

    any advice you guys can offer will be greatly appreciated

    cheeeeeers

  2. #2
    iluxa is offline Senior Member
    Join Date
    Mar 2010
    Posts
    266
    Rep Power
    5

    Default

    step by step.

    1. Parse the XML using DOM.
    2. Count the nodes.
    3. Choose a random node.

    google those one at a time.

Similar Threads

  1. random file access and GUI
    By leiferouis in forum New To Java
    Replies: 1
    Last Post: 02-19-2009, 04:21 AM
  2. Random File Access
    By viper110110 in forum New To Java
    Replies: 11
    Last Post: 11-28-2008, 12:28 AM
  3. Random access to text file
    By lunarbof in forum New To Java
    Replies: 1
    Last Post: 11-05-2008, 08:53 PM
  4. Cannot display a random string from .dat file
    By explosion242 in forum New To Java
    Replies: 2
    Last Post: 09-18-2008, 01:48 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •