Jump to content

XML and PHP


cry of war

Recommended Posts

I am creating a website that I want to use XML files as storage. I have ran into a few problems or concerns on the topic and was wondering if you could help me.

 

1. Will people be able to view the XML files if they know the root of the dir.

2. Will I be able to add/delete nodes without having to rewrite the whole file.

3. Is there a better way to do this?

 

 

Thank you for your time.

Link to comment
Share on other sites

I think the problem you're going to have with an XML is relationships.

XML is great at storing tree heirarchy, and sets of information, but unfortunately is rubbish at being a relational model. The biggest problem you face is getting back searches/joins between your xml files. Best get to learning xpath ;)

Link to comment
Share on other sites

The reason I want to use xml is because there are some areas that i think will be to complex for the DB server or my skill in SQL DB is horrible. For example I am making a game. The users have weapons and those weapons have certain skills that they can use having different ranges attack power and so on. If my admins wanted to one of them i would have to creat a new column in the SQL table but if I were to make it in the XML file i could Add up to millions of Skills on that one weapon.

Link to comment
Share on other sites

Weapons have skills  :o

My friend, think about it this way:

Weapons have attributes (range, recharge time, weight)

People have skills (quick fire, slow fire, arcane shot)

 

There's no reason why this can't be stored in a database. Blizzard do it for World of Warcraft easily enough...

Link to comment
Share on other sites

ok let me re-phrase that weapon skills= weapon arts

 

And there is alot more of these so you have to remember that im turning i think it was 46 tables into 1 (User log info)plus XML sheets if I use XML

Data base examples

 

Weapons

/--------------\/--------------\/--------------\/--------------\

|-----ID-------|-----Name-----|---StrBonus---|----Agility-----|and so on

\--------------/\--------------/\--------------/\--------------/

|-----1--------|-Throwing Axe-|-----1---------|---9----------|

|-----2--------|-Meat Cleaver-|-----99--------|----3---------|

 

Arts

/--------------\/--------------\/--------------\/--------------\/--------------\

|-----ID-------|-----Name-----|------Bonus---|----Alignment-|----Target-----|

\--------------/\--------------/\--------------/\--------------/\--------------/

|-----1--------|-Lucky Shot---|-----Luck------|---10---------|----1-----|

|-----1--------|-Lucky Shot---|-----Accuarcy-|---7---------|----1-----|

|-----2--------|-Mad Man-----|-----Strength--|----3---------|----1-----|

|-----1--------|-Sniper--------|-----Accuarcy-|---9----------|----1-----|

|-----2--------|-Dismember---|-----Speed-----|-----6---------|----2-----|

 

xml

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<Weapons>

<Weapon>

<ID>#156763453</ID>

<Name>Throwing Axe</Name>

<Art>

<ID>#1456378342</ID>

<Name>Lucky Shot</Name>

<Effect>

<Bonus>Luck</Bonus>

<Alignment>10</Alignment>

<Target>1</Target>

</Effect>

<Effect>

<Bonus>Accuarcy</Bonus>

<Alignment>7</Alignment>

<Target>1</Target>

</Effect>

</Art>

<Art>

<ID>#183243748735</ID>

<Name>Sniper</Name>

<Effect>

<Bonus>Accuarcy</Bonus>

<Alignment>9</Alignment>

<Target>1</Target>

</Effect>

</Art>

</Weapon>

<Weapon>

<ID>#9845868</ID>

<Name>Meat Cleaver</Name>

<Art>

<ID>#1488784685</ID>

<Name>Mad Man</Name>

<Effect>

<Bonus>Strength</Bonus>

<Alignment>3</Alignment>

<Target>1</Target>

</Effect>

</Art>

<Art>

<ID>#5496851255</ID>

<Name>Dismember</Name>

<Effect>

<Bonus>Speed</Bonus>

<Alignment>6</Alignment>

<Target>2</Target>

</Effect>

</Art>

</Weapon>

</Weapons>

 

 

Then with this i should just be able to Delete the Node which would be about the same as with a SQL DB right well minus all the xpath stuff i have to learn i suppose

 

The weapon System for my game is pretty complex

 

gem+hilt+blade+art+stats+info=weapon

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.