tags:

views:

206

answers:

1

Hi all,

I was wondering if anyone knows how to get information from an XML file and turn it into a form select/list using php.. This is the XML schema:

<?xml version="1.0" encoding="utf-8"?>
<expose version="2.1">
  <collection _mngid="1">
    <collection _mngid="1">
      <title>Heatherton Football Club</title>
      <thumb>
        <url>albthumbs/albth_1.jpg</url>
      </thumb>
      <collection _mngid="8">
        <title>2009 Season</title>
        <thumb>
          <url>albthumbs/albth_8.jpg</url>
        </thumb>
        <album _mngid="2">
          <title>Round 17</title>
          <contentxmlurl>alb_2.xml</contentxmlurl>
          <contentnumber>20</contentnumber>
          <thumb>
            <url>albthumbs/albth_2.jpg</url>
          </thumb>
        </album>
      </collection>
      <album _mngid="3">
        <title>Auskick</title>
        <contentxmlurl>alb_3.xml</contentxmlurl>
        <contentnumber>35</contentnumber>
        <thumb>
          <url>albthumbs/albth_3.jpg</url>
        </thumb>
      </album>
    </collection>
    <collection _mngid="4">
      <title>Events Gallery</title>
      <thumb>
        <url>albthumbs/albth_4.jpg</url>
      </thumb>
      <album _mngid="5">
        <title>80's Night</title>
        <contentxmlurl>alb_5.xml</contentxmlurl>
        <contentnumber>43</contentnumber>
        <thumb>
          <url>albthumbs/albth_5.jpg</url>
        </thumb>
      </album>
    </collection>
    <collection _mngid="6">
      <title>Match Highlights</title>
      <thumb>
        <url>albthumbs/albth_6.jpg</url>
      </thumb>
      <album _mngid="7">
        <title>Match Highlights</title>
        <contentxmlurl>alb_7.xml</contentxmlurl>
        <contentnumber>10</contentnumber>
        <thumb>
          <url>albthumbs/albth_7.jpg</url>
        </thumb>
      </album>
    </collection>
  </collection>
</expose>

I need the "contentnumber" number and the "title" to create a form select/list like this:

<select name="select" id="select">
  <option value="20">Round 17</option>
  <option value="35">Auskick</option>
  <option value="43">80's Night</option>
  <option value="10">Match Highlights</option>
</select>

Is this even possible? I just need the ones with a "contentnumber" (and of course it's "title") It needs to be dynamically pulled in via php :) Can anyone help me out?

+2  A: 

You need a XML parser (SimpleXML) that will parse this XML to something PHP can work with (an object in case of SimpleXML) that you can use to dynamically create your select box.

RaYell