XML : How to get values from XML

I'm using PHP. I am novice at XML. I want to set all the values as variables to use elsewhere.

For example, <property name="HoldType" value="4" /> I want to set $holdtype_value to equal 4.

Further complication; <property class="Action0"> has a child property with name="Class", so does the Action1 property. I need a variable for those values.

Here is an example item from the XML. Some items have more or less properties.

      <item id="24" name="hoe">      <property name="Meshfile" value="Items/Tools/hoe_iron" />      <property name="Material" value="metal" />      <property name="HoldType" value="4" />      <property name="Stacknumber" value="1" />      <property name="RepairTools" value="forgedIron" />      <property name="Degradation" value="300" param1="true" />      <property name="SoundDestroy" value="wooddestroy1" />      <property name="FuelValue" value="24" />      <property name="Weight" value="32" />      <property class="Action0">          <!-- AttackAction -->          <property name="Class" value="Melee" />          <property name="Delay" value="2.1" />          <property name="Range" value="2" />          <property name="Sphere" value="0.2" />          <property name="Block_range" value="4" />          <property name="DamageEntity" value="5" />          <property name="DamageBlock" value="1" />          <property name="Sound_start" value="swoosh" />          <property name="Stamina_usage" value="8" />          <property name="DamageBonus.earth" value="2" />          <property name="DamageBonus.glass" value="25" />          <property name="DamageBonus.head" value="4" />      </property>      <property class="Action1">          <!-- UseAction -->          <property name="Class" value="MakeFertile" />          <property name="Delay" value="2.1" />          <property name="Block_range" value="4" />          <property name="DamageBlock" value="1" />          <property name="Sound_start" value="swoosh" />          <property name="Sound_end" value="UseActions/repair_block" />          <property name="Fertileblock" value="fertileFarmland" />          <property name="Adjacentblock" value="dirt" />      </property>      <property name="Group" value="Tools/Traps" />      <property class="Preview">          <property name="Zoom" value="0" />          <property name="Pos" value="0,0" />      </property>      <property name="ActionSkillGroup" value="Mining Tools"/>      <property name="CraftingSkillGroup" value="Tool Smithing"/>  </item>    

No comments:

Post a Comment