Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read XML attribs PHP 4.3.10

Status
Not open for further replies.

spelltwister

Programmer
May 12, 2005
36
0
0
US
Hey all,

I'm having a hard time finding any examples of parsing XML that has attributes.

Here's the xml:

<units>
<persiancamp unit="infantry" number="8" owner="persian" ranged="0" />
<persiancamp unit="xerxes" number="1" owner="persian" ranged="0" />
<m1 unit="sInfantry" number="1" owner="persian" ranged="1" />
<...>
</units>

I have an array with all possible tag names and I need to be able to do something like this:

$array = array('persiancamp','m1'...);
for($i=0;$i<sizeof($array);$i++){

//CYCLE THROUGH XML FINDING IF TAGS MATCH CURRENT ARRAY VALUE, GATHER ALL ATTRIBUTE INFORMATION

}


Any help, or links to tutorials are much appreciated.

Thanks!

Mike

Online multiplayer strategy games huh? Try, 1483online.com where the games are FREE and the community drives enhancements to the game. ;-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top