XML Question

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
aliasxneo
Forum Contributor
Posts: 136
Joined: Thu Aug 31, 2006 12:01 am

XML Question

Post by aliasxneo »

I've not gone too much into XML, no particular reason just never got around to it I suppose. I've mostly just used it to quickly store and load things but have never gone much further.

My question is, what are the "rules" to XML? For instance I've never clearly understood when I should use attributes or not. I know there are general rules when formatting it, but I can't seem to find a tutorial that simply lists them (without going into nonsense I really don't need to know).

I've started work on a configuration system for one of my scripts and I've decided to use XML to format the configuration data. Here is the sample I created and am working with:

Code: Select all

<config>
    <admin username="test" password="45093">
    <members>
        <member id="1" name="2">
            <ip>343.4.34.33</ip>
            <ip>53.56.235.63</ip>
        </member>
    </members>
</config>
Is there anything "wrong" with this? I.E should id be a node and not an attribute?

Also, if anyone can point me to some good XML tutorials that only discuss proper formatting (with examples) that would be helpful. I really prefer to do this right the first time ;)

Thanks.

~ Josh
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: XML Question

Post by kendall »

Actually its almost a good xml document...

you should probably <admin username="test" password="45093"/> // note the self closing of the tag

I would try topXML and 3WC website for some definitive references and http://www.sitepoint.com for some tutorials :wink:
Post Reply