#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    206
    Rep Power
    11

    Help needed with XML file structure


    Hi,

    I'm a newbie to XML, with a problem. I want to create an XML file of events. Each event has a name, date and a number of links associated with it.

    So it would be :
    Name: Dogs v Cats
    Date: 12/12/2013
    Link: http://www.link1.com
    Link: http://www.link2.com
    Link: http://www.link3.com


    Name: Birds v Ferrets
    Date: 11/12/2013
    Link: http://www.link4.com
    Link: http://www.link5.com
    Link: http://www.link6.com

    Any idea on the best way to structure my XML file?

    Thanks in advance!
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,119
    Rep Power
    9398
    Each of those is some type of thing. I'll guess at them being "events". (Could be shows or movies or whatever.) There's always a handful of options for how the XML looks and which you choose kinda depends on the tools you're using - one option may be easier to work with than another.

    Example 1: no attributes, typically easier to use
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <events>
    	<event>
    		<name>Dogs v Cats</name>
    		<date>12/12/2013</date>
    		<link>http://www.link1.com</link>
    		<link>http://www.link2.com</link>
    		<link>http://www.link3.com</link>
    	</event>
    </events>
    Example 2: with attributes, looks cleaner (IMO)
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <events>
    	<event name="Birds v Ferrets" date="11/12/2013">
    		<link>http://www.link4.com</link>
    		<link>http://www.link5.com</link>
    		<link>http://www.link6.com</link>
    	</event>
    </events>

IMN logo majestic logo threadwatch logo seochat tools logo