Solved

XML to database

Posted on 2009-04-11
13
338 Views
Last Modified: 2013-12-12
Hi all,

As you can see in the code that I provided I have an XML Sheet that I need to extract data from. How can I extract the following information from the XML Sheet and insert it into a database.

I know how to insert data into a database but extracting data from this XML i'm finding hard.


If someone could provide me with the code I would be very greatful.

Thanks

Billy
<Show>

<name>Buffy the Vampire Slayer</name>

<totalseasons>7</totalseasons>



<Episodelist>



<Season no="0">



<episode>

<epnum>0</epnum>

<seasonnum>00</seasonnum>

<prodnum>4V79</prodnum>

<airdate>0000-00-00</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/329033

</link>

<title>Unaired Pilot</title>

</episode>

</Season>



<Season no="1">



<episode>

<epnum>1</epnum>

<seasonnum>01</seasonnum>

<prodnum>4V01</prodnum>

<airdate>1997-03-10</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28077

</link>

<title>Welcome to the Hellmouth (1)</title>

</episode>



<episode>

<epnum>2</epnum>

<seasonnum>02</seasonnum>

<prodnum>4V02</prodnum>

<airdate>1997-03-10</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28078

</link>

<title>The Harvest (2)</title>

</episode>



<episode>

<epnum>3</epnum>

<seasonnum>03</seasonnum>

<prodnum>4V03</prodnum>

<airdate>1997-03-17</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28079

</link>

<title>The Witch</title>

</episode>



<episode>

<epnum>4</epnum>

<seasonnum>04</seasonnum>

<prodnum>4V04</prodnum>

<airdate>1997-03-25</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28080

</link>

<title>Teacher's Pet</title>

</episode>



<episode>

<epnum>5</epnum>

<seasonnum>05</seasonnum>

<prodnum>4V05</prodnum>

<airdate>1997-03-31</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28081

</link>

<title>Never Kill a Boy on the First Date</title>

</episode>



<episode>

<epnum>6</epnum>

<seasonnum>06</seasonnum>

<prodnum>4V06</prodnum>

<airdate>1997-04-07</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28082

</link>

<title>The Pack</title>

</episode>



<episode>

<epnum>7</epnum>

<seasonnum>07</seasonnum>

<prodnum>4V07</prodnum>

<airdate>1997-04-14</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28083

</link>

<title>Angel</title>

</episode>



<episode>

<epnum>8</epnum>

<seasonnum>08</seasonnum>

<prodnum>4V08</prodnum>

<airdate>1997-04-28</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28084

</link>

<title>I, Robot... You, Jane</title>

</episode>



<episode>

<epnum>9</epnum>

<seasonnum>09</seasonnum>

<prodnum>4V09</prodnum>

<airdate>1997-05-05</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28085

</link>

<title>The Puppet Show</title>

</episode>



<episode>

<epnum>10</epnum>

<seasonnum>10</seasonnum>

<prodnum>4V10</prodnum>

<airdate>1997-05-12</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28086

</link>

<title>Nightmares</title>

</episode>



<episode>

<epnum>11</epnum>

<seasonnum>11</seasonnum>

<prodnum>4V11</prodnum>

<airdate>1997-05-19</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28087

</link>

<title>Out of Mind, Out of Sight</title>

</episode>



<episode>

<epnum>12</epnum>

<seasonnum>12</seasonnum>

<prodnum>4V12</prodnum>

<airdate>1997-06-02</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28088

</link>

<title>Prophecy Girl</title>

</episode>

</Season>



<Season no="2">



<episode>

<epnum>13</epnum>

<seasonnum>01</seasonnum>

<prodnum>5V01</prodnum>

<airdate>1997-09-15</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28089

</link>

<title>When She Was Bad</title>

</episode>



<episode>

<epnum>14</epnum>

<seasonnum>02</seasonnum>

<prodnum>5V02</prodnum>

<airdate>1997-09-22</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28090

</link>

<title>Some Assembly Required</title>

</episode>



<episode>

<epnum>15</epnum>

<seasonnum>03</seasonnum>

<prodnum>5V03</prodnum>

<airdate>1997-09-29</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28091

</link>

<title>School Hard</title>

</episode>



<episode>

<epnum>16</epnum>

<seasonnum>04</seasonnum>

<prodnum>5V04</prodnum>

<airdate>1997-10-06</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28092

</link>

<title>Inca Mummy Girl</title>

</episode>



<episode>

<epnum>17</epnum>

<seasonnum>05</seasonnum>

<prodnum>5V05</prodnum>

<airdate>1997-10-13</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28093

</link>

<title>Reptile Boy</title>

</episode>



<episode>

<epnum>18</epnum>

<seasonnum>06</seasonnum>

<prodnum>5V06</prodnum>

<airdate>1997-10-27</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28094

</link>

<title>Halloween</title>

</episode>



<episode>

<epnum>19</epnum>

<seasonnum>07</seasonnum>

<prodnum>5V07</prodnum>

<airdate>1997-11-03</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28095

</link>

<title>Lie to Me</title>

</episode>



<episode>

<epnum>20</epnum>

<seasonnum>08</seasonnum>

<prodnum>5V08</prodnum>

<airdate>1997-11-10</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28096

</link>

<title>The Dark Age</title>

</episode>



<episode>

<epnum>21</epnum>

<seasonnum>09</seasonnum>

<prodnum>5V09</prodnum>

<airdate>1997-11-17</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28097

</link>

<title>What's My Line? (1)</title>

</episode>



<episode>

<epnum>22</epnum>

<seasonnum>10</seasonnum>

<prodnum>5V10</prodnum>

<airdate>1997-11-24</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28098

</link>

<title>What's My Line? (2)</title>

</episode>



<episode>

<epnum>23</epnum>

<seasonnum>11</seasonnum>

<prodnum>5V11</prodnum>

<airdate>1997-12-08</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28099

</link>

<title>Ted</title>

</episode>



<episode>

<epnum>24</epnum>

<seasonnum>12</seasonnum>

<prodnum>5V12</prodnum>

<airdate>1998-01-12</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28100

</link>

<title>Bad Eggs</title>

</episode>



<episode>

<epnum>25</epnum>

<seasonnum>13</seasonnum>

<prodnum>5V13</prodnum>

<airdate>1998-01-19</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28101

</link>

<title>Surprise (1)</title>

</episode>



<episode>

<epnum>26</epnum>

<seasonnum>14</seasonnum>

<prodnum>5V14</prodnum>

<airdate>1998-01-20</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28102

</link>

<title>Innocence (2)</title>

</episode>



<episode>

<epnum>27</epnum>

<seasonnum>15</seasonnum>

<prodnum>5V15</prodnum>

<airdate>1998-01-27</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28103

</link>

<title>Phases</title>

</episode>



<episode>

<epnum>28</epnum>

<seasonnum>16</seasonnum>

<prodnum>5V16</prodnum>

<airdate>1998-02-10</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28104

</link>

<title>Bewitched, Bothered and Bewildered</title>

</episode>



<episode>

<epnum>29</epnum>

<seasonnum>17</seasonnum>

<prodnum>5V17</prodnum>

<airdate>1998-02-24</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28105

</link>

<title>Passion</title>

</episode>



<episode>

<epnum>30</epnum>

<seasonnum>18</seasonnum>

<prodnum>5V18</prodnum>

<airdate>1998-03-03</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28106

</link>

<title>Killed by Death</title>

</episode>



<episode>

<epnum>31</epnum>

<seasonnum>19</seasonnum>

<prodnum>5V19</prodnum>

<airdate>1998-04-28</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28107

</link>

<title>I Only Have Eyes For You</title>

</episode>



<episode>

<epnum>32</epnum>

<seasonnum>20</seasonnum>

<prodnum>5V20</prodnum>

<airdate>1998-05-05</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28108

</link>

<title>Go Fish</title>

</episode>



<episode>

<epnum>33</epnum>

<seasonnum>21</seasonnum>

<prodnum>5V21</prodnum>

<airdate>1998-05-12</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28109

</link>

<title>Becoming (1)</title>

</episode>



<episode>

<epnum>34</epnum>

<seasonnum>22</seasonnum>

<prodnum>5V22</prodnum>

<airdate>1998-05-19</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28110

</link>

<title>Becoming (2)</title>

</episode>

</Season>



<Season no="3">



<episode>

<epnum>35</epnum>

<seasonnum>01</seasonnum>

<prodnum>3ABB01</prodnum>

<airdate>1998-09-29</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28111

</link>

<title>Anne</title>

</episode>



<episode>

<epnum>36</epnum>

<seasonnum>02</seasonnum>

<prodnum>3ABB02</prodnum>

<airdate>1998-10-06</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28112

</link>

<title>Dead Man's Party</title>

</episode>



<episode>

<epnum>37</epnum>

<seasonnum>03</seasonnum>

<prodnum>3ABB03</prodnum>

<airdate>1998-10-13</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28113

</link>

<title>Faith, Hope & Trick</title>

</episode>



<episode>

<epnum>38</epnum>

<seasonnum>04</seasonnum>

<prodnum>3ABB04</prodnum>

<airdate>1998-10-20</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28114

</link>

<title>Beauty and the Beasts</title>

</episode>



<episode>

<epnum>39</epnum>

<seasonnum>05</seasonnum>

<prodnum>3ABB05</prodnum>

<airdate>1998-11-03</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28115

</link>

<title>Homecoming</title>

</episode>



<episode>

<epnum>40</epnum>

<seasonnum>06</seasonnum>

<prodnum>3ABB06</prodnum>

<airdate>1998-11-10</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28116

</link>

<title>Band Candy</title>

</episode>



<episode>

<epnum>41</epnum>

<seasonnum>07</seasonnum>

<prodnum>3ABB07</prodnum>

<airdate>1998-11-17</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28117

</link>

<title>Revelations</title>

</episode>



<episode>

<epnum>42</epnum>

<seasonnum>08</seasonnum>

<prodnum>3ABB08</prodnum>

<airdate>1998-11-24</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28118

</link>

<title>Lover's Walk</title>

</episode>



<episode>

<epnum>43</epnum>

<seasonnum>09</seasonnum>

<prodnum>3ABB09</prodnum>

<airdate>1998-12-08</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28119

</link>

<title>The Wish</title>

</episode>



<episode>

<epnum>44</epnum>

<seasonnum>10</seasonnum>

<prodnum>3ABB10</prodnum>

<airdate>1998-12-15</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28120

</link>

<title>Amends</title>

</episode>



<episode>

<epnum>45</epnum>

<seasonnum>11</seasonnum>

<prodnum>3ABB11</prodnum>

<airdate>1999-01-12</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28121

</link>

<title>Gingerbread</title>

</episode>



<episode>

<epnum>46</epnum>

<seasonnum>12</seasonnum>

<prodnum>3ABB12</prodnum>

<airdate>1999-01-19</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28122

</link>

<title>Helpless</title>

</episode>



<episode>

<epnum>47</epnum>

<seasonnum>13</seasonnum>

<prodnum>3ABB13</prodnum>

<airdate>1999-01-26</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28123

</link>

<title>The Zeppo</title>

</episode>



<episode>

<epnum>48</epnum>

<seasonnum>14</seasonnum>

<prodnum>3ABB14</prodnum>

<airdate>1999-02-09</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28124

</link>

<title>Bad Girls</title>

</episode>



<episode>

<epnum>49</epnum>

<seasonnum>15</seasonnum>

<prodnum>3ABB15</prodnum>

<airdate>1999-02-16</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28125

</link>

<title>Consequences</title>

</episode>



<episode>

<epnum>50</epnum>

<seasonnum>16</seasonnum>

<prodnum>3ABB16</prodnum>

<airdate>1999-02-23</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28126

</link>

<title>Doppelgangland</title>

</episode>



<episode>

<epnum>51</epnum>

<seasonnum>17</seasonnum>

<prodnum>3ABB17</prodnum>

<airdate>1999-03-16</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28127

</link>

<title>Enemies</title>

</episode>



<episode>

<epnum>52</epnum>

<seasonnum>18</seasonnum>

<prodnum>3ABB18</prodnum>

<airdate>1999-09-21</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28128

</link>

<title>Earshot</title>

</episode>



<episode>

<epnum>53</epnum>

<seasonnum>19</seasonnum>

<prodnum>3ABB19</prodnum>

<airdate>1999-05-04</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28129

</link>

<title>Choices</title>

</episode>



<episode>

<epnum>54</epnum>

<seasonnum>20</seasonnum>

<prodnum>3ABB20</prodnum>

<airdate>1999-05-11</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28130

</link>

<title>The Prom</title>

</episode>



<episode>

<epnum>55</epnum>

<seasonnum>21</seasonnum>

<prodnum>3ABB21</prodnum>

<airdate>1999-05-18</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28131

</link>

<title>Graduation Day (1)</title>

</episode>



<episode>

<epnum>56</epnum>

<seasonnum>22</seasonnum>

<prodnum>3ABB22</prodnum>

<airdate>1999-07-13</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28132

</link>

<title>Graduation Day (2)</title>

</episode>

</Season>



<Season no="4">



<episode>

<epnum>57</epnum>

<seasonnum>01</seasonnum>

<prodnum>4ABB01</prodnum>

<airdate>1999-10-05</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28133

</link>

<title>The Freshman</title>

</episode>



<episode>

<epnum>58</epnum>

<seasonnum>02</seasonnum>

<prodnum>4ABB02</prodnum>

<airdate>1999-10-12</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28134

</link>

<title>Living Conditions</title>

</episode>



<episode>

<epnum>59</epnum>

<seasonnum>03</seasonnum>

<prodnum>4ABB03</prodnum>

<airdate>1999-10-19</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28135

</link>

<title>The Harsh Light of Day</title>

</episode>



<episode>

<epnum>60</epnum>

<seasonnum>04</seasonnum>

<prodnum>4ABB04</prodnum>

<airdate>1999-10-26</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28136

</link>

<title>Fear, Itself</title>

</episode>



<episode>

<epnum>61</epnum>

<seasonnum>05</seasonnum>

<prodnum>4ABB05</prodnum>

<airdate>1999-11-02</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28137

</link>

<title>Beer Bad</title>

</episode>



<episode>

<epnum>62</epnum>

<seasonnum>06</seasonnum>

<prodnum>4ABB06</prodnum>

<airdate>1999-11-09</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28138

</link>

<title>Wild At Heart</title>

</episode>



<episode>

<epnum>63</epnum>

<seasonnum>07</seasonnum>

<prodnum>4ABB07</prodnum>

<airdate>1999-11-16</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28139

</link>

<title>The Initiative</title>

</episode>



<episode>

<epnum>64</epnum>

<seasonnum>08</seasonnum>

<prodnum>4ABB08</prodnum>

<airdate>1999-11-23</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28140

</link>

<title>Pangs</title>

</episode>



<episode>

<epnum>65</epnum>

<seasonnum>09</seasonnum>

<prodnum>4ABB09</prodnum>

<airdate>1999-11-30</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28141

</link>

<title>Something Blue</title>

</episode>



<episode>

<epnum>66</epnum>

<seasonnum>10</seasonnum>

<prodnum>4ABB10</prodnum>

<airdate>1999-12-14</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28142

</link>

<title>Hush</title>

</episode>



<episode>

<epnum>67</epnum>

<seasonnum>11</seasonnum>

<prodnum>4ABB11</prodnum>

<airdate>2000-01-18</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28143

</link>

<title>Doomed</title>

</episode>



<episode>

<epnum>68</epnum>

<seasonnum>12</seasonnum>

<prodnum>4ABB12</prodnum>

<airdate>2000-01-25</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28144

</link>

<title>A New Man</title>

</episode>



<episode>

<epnum>69</epnum>

<seasonnum>13</seasonnum>

<prodnum>4ABB13</prodnum>

<airdate>2000-02-08</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28145

</link>

<title>The I In Team</title>

</episode>



<episode>

<epnum>70</epnum>

<seasonnum>14</seasonnum>

<prodnum>4ABB14</prodnum>

<airdate>2000-02-15</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28146

</link>

<title>Goodbye Iowa</title>

</episode>



<episode>

<epnum>71</epnum>

<seasonnum>15</seasonnum>

<prodnum>4ABB15</prodnum>

<airdate>2000-02-22</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28147

</link>

<title>This Year's Girl (1)</title>

</episode>



<episode>

<epnum>72</epnum>

<seasonnum>16</seasonnum>

<prodnum>4ABB16</prodnum>

<airdate>2000-02-29</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28148

</link>

<title>Who Are You? (2)</title>

</episode>



<episode>

<epnum>73</epnum>

<seasonnum>17</seasonnum>

<prodnum>4ABB17</prodnum>

<airdate>2000-04-04</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28149

</link>

<title>Superstar</title>

</episode>



<episode>

<epnum>74</epnum>

<seasonnum>18</seasonnum>

<prodnum>4ABB18</prodnum>

<airdate>2000-04-25</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28150

</link>

<title>Where the Wild Things Are</title>

</episode>



<episode>

<epnum>75</epnum>

<seasonnum>19</seasonnum>

<prodnum>4ABB19</prodnum>

<airdate>2000-05-02</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28151

</link>

<title>New Moon Rising</title>

</episode>



<episode>

<epnum>76</epnum>

<seasonnum>20</seasonnum>

<prodnum>4ABB20</prodnum>

<airdate>2000-05-09</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28152

</link>

<title>The Yoko Factor (1)</title>

</episode>



<episode>

<epnum>77</epnum>

<seasonnum>21</seasonnum>

<prodnum>4ABB21</prodnum>

<airdate>2000-05-16</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28153

</link>

<title>Primeval (2)</title>

</episode>



<episode>

<epnum>78</epnum>

<seasonnum>22</seasonnum>

<prodnum>4ABB22</prodnum>

<airdate>2000-05-23</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28154

</link>

<title>Restless</title>

</episode>

</Season>



<Season no="5">



<episode>

<epnum>79</epnum>

<seasonnum>01</seasonnum>

<prodnum>5ABB01</prodnum>

<airdate>2000-09-26</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28155

</link>

<title>Buffy vs. Dracula</title>

</episode>



<episode>

<epnum>80</epnum>

<seasonnum>02</seasonnum>

<prodnum>5ABB02</prodnum>

<airdate>2000-10-03</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28156

</link>

<title>Real Me</title>

</episode>



<episode>

<epnum>81</epnum>

<seasonnum>03</seasonnum>

<prodnum>5ABB03</prodnum>

<airdate>2000-10-10</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28157

</link>

<title>The Replacement</title>

</episode>



<episode>

<epnum>82</epnum>

<seasonnum>04</seasonnum>

<prodnum>5ABB04</prodnum>

<airdate>2000-10-17</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28158

</link>

<title>Out of My Mind</title>

</episode>



<episode>

<epnum>83</epnum>

<seasonnum>05</seasonnum>

<prodnum>5ABB05</prodnum>

<airdate>2000-10-24</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28159

</link>

<title>No Place Like Home</title>

</episode>



<episode>

<epnum>84</epnum>

<seasonnum>06</seasonnum>

<prodnum>5ABB06</prodnum>

<airdate>2000-11-07</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28160

</link>

<title>Family</title>

</episode>



<episode>

<epnum>85</epnum>

<seasonnum>07</seasonnum>

<prodnum>5ABB07</prodnum>

<airdate>2000-11-14</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28161

</link>

<title>Fool for Love</title>

</episode>



<episode>

<epnum>86</epnum>

<seasonnum>08</seasonnum>

<prodnum>5ABB08</prodnum>

<airdate>2000-11-21</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28162

</link>

<title>Shadow</title>

</episode>



<episode>

<epnum>87</epnum>

<seasonnum>09</seasonnum>

<prodnum>5ABB09</prodnum>

<airdate>2000-11-28</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28163

</link>

<title>Listening to Fear</title>

</episode>



<episode>

<epnum>88</epnum>

<seasonnum>10</seasonnum>

<prodnum>5ABB10</prodnum>

<airdate>2000-12-19</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28164

</link>

<title>Into the Woods</title>

</episode>



<episode>

<epnum>89</epnum>

<seasonnum>11</seasonnum>

<prodnum>5ABB11</prodnum>

<airdate>2001-01-09</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28165

</link>

<title>Triangle</title>

</episode>



<episode>

<epnum>90</epnum>

<seasonnum>12</seasonnum>

<prodnum>5ABB12</prodnum>

<airdate>2001-01-23</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28166

</link>

<title>Checkpoint</title>

</episode>



<episode>

<epnum>91</epnum>

<seasonnum>13</seasonnum>

<prodnum>5ABB13</prodnum>

<airdate>2001-02-06</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28167

</link>

<title>Blood Ties</title>

</episode>



<episode>

<epnum>92</epnum>

<seasonnum>14</seasonnum>

<prodnum>5ABB14</prodnum>

<airdate>2001-02-13</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28168

</link>

<title>Crush</title>

</episode>



<episode>

<epnum>93</epnum>

<seasonnum>15</seasonnum>

<prodnum>5ABB15</prodnum>

<airdate>2001-02-20</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28169

</link>

<title>I Was Made to Love You</title>

</episode>



<episode>

<epnum>94</epnum>

<seasonnum>16</seasonnum>

<prodnum>5ABB16</prodnum>

<airdate>2001-02-27</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28170

</link>

<title>The Body</title>

</episode>



<episode>

<epnum>95</epnum>

<seasonnum>17</seasonnum>

<prodnum>5ABB17</prodnum>

<airdate>2001-04-17</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28171

</link>

<title>Forever</title>

</episode>



<episode>

<epnum>96</epnum>

<seasonnum>18</seasonnum>

<prodnum>5ABB18</prodnum>

<airdate>2001-04-24</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28172

</link>

<title>Intervention</title>

</episode>



<episode>

<epnum>97</epnum>

<seasonnum>19</seasonnum>

<prodnum>5ABB19</prodnum>

<airdate>2001-05-01</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28173

</link>

<title>Tough Love</title>

</episode>



<episode>

<epnum>98</epnum>

<seasonnum>20</seasonnum>

<prodnum>5ABB20</prodnum>

<airdate>2001-05-08</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28174

</link>

<title>Spiral</title>

</episode>



<episode>

<epnum>99</epnum>

<seasonnum>21</seasonnum>

<prodnum>5ABB21</prodnum>

<airdate>2001-05-15</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28175

</link>

<title>The Weight of the World</title>

</episode>



<episode>

<epnum>100</epnum>

<seasonnum>22</seasonnum>

<prodnum>5ABB22</prodnum>

<airdate>2001-05-22</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28176

</link>

<title>The Gift</title>

</episode>

</Season>



<Season no="6">



<episode>

<epnum>101</epnum>

<seasonnum>01</seasonnum>

<prodnum>6ABB01</prodnum>

<airdate>2001-10-02</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28177

</link>

<title>Bargaining (1)</title>

</episode>



<episode>

<epnum>102</epnum>

<seasonnum>02</seasonnum>

<prodnum>6ABB02</prodnum>

<airdate>2001-10-02</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28178

</link>

<title>Bargaining (2)</title>

</episode>



<episode>

<epnum>103</epnum>

<seasonnum>03</seasonnum>

<prodnum>6ABB03</prodnum>

<airdate>2001-10-09</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28179

</link>

<title>After Life</title>

</episode>



<episode>

<epnum>104</epnum>

<seasonnum>04</seasonnum>

<prodnum>6ABB04</prodnum>

<airdate>2001-10-16</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28180

</link>

<title>Flooded</title>

</episode>



<episode>

<epnum>105</epnum>

<seasonnum>05</seasonnum>

<prodnum>6ABB05</prodnum>

<airdate>2001-10-23</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28181

</link>

<title>Life Serial</title>

</episode>



<episode>

<epnum>106</epnum>

<seasonnum>06</seasonnum>

<prodnum>6ABB06</prodnum>

<airdate>2001-10-30</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28182

</link>

<title>All The Way</title>

</episode>



<episode>

<epnum>107</epnum>

<seasonnum>07</seasonnum>

<prodnum>6ABB07</prodnum>

<airdate>2001-11-06</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28183

</link>

<title>Once More, With Feeling</title>

</episode>



<episode>

<epnum>108</epnum>

<seasonnum>08</seasonnum>

<prodnum>6ABB08</prodnum>

<airdate>2001-11-13</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28184

</link>

<title>Tabula Rasa</title>

</episode>



<episode>

<epnum>109</epnum>

<seasonnum>09</seasonnum>

<prodnum>6ABB09</prodnum>

<airdate>2001-11-20</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28185

</link>

<title>Smashed</title>

</episode>



<episode>

<epnum>110</epnum>

<seasonnum>10</seasonnum>

<prodnum>6ABB10</prodnum>

<airdate>2001-11-27</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28186

</link>

<title>Wrecked</title>

</episode>



<episode>

<epnum>111</epnum>

<seasonnum>11</seasonnum>

<prodnum>6ABB11</prodnum>

<airdate>2002-01-08</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28187

</link>

<title>Gone</title>

</episode>



<episode>

<epnum>112</epnum>

<seasonnum>12</seasonnum>

<prodnum>6ABB12</prodnum>

<airdate>2002-01-29</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28188

</link>

<title>Doublemeat Palace</title>

</episode>



<episode>

<epnum>113</epnum>

<seasonnum>13</seasonnum>

<prodnum>6ABB13</prodnum>

<airdate>2002-02-05</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28189

</link>

<title>Dead Things</title>

</episode>



<episode>

<epnum>114</epnum>

<seasonnum>14</seasonnum>

<prodnum>6ABB14</prodnum>

<airdate>2002-02-12</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28190

</link>

<title>Older and Far Away</title>

</episode>



<episode>

<epnum>115</epnum>

<seasonnum>15</seasonnum>

<prodnum>6ABB15</prodnum>

<airdate>2002-02-26</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28191

</link>

<title>As You Were</title>

</episode>



<episode>

<epnum>116</epnum>

<seasonnum>16</seasonnum>

<prodnum>6ABB16</prodnum>

<airdate>2002-03-05</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28192

</link>

<title>Hell's Bells</title>

</episode>



<episode>

<epnum>117</epnum>

<seasonnum>17</seasonnum>

<prodnum>6ABB17</prodnum>

<airdate>2002-03-12</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28193

</link>

<title>Normal Again</title>

</episode>



<episode>

<epnum>118</epnum>

<seasonnum>18</seasonnum>

<prodnum>6ABB18</prodnum>

<airdate>2002-04-30</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28194

</link>

<title>Entropy</title>

</episode>



<episode>

<epnum>119</epnum>

<seasonnum>19</seasonnum>

<prodnum>6ABB19</prodnum>

<airdate>2002-05-07</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28195

</link>

<title>Seeing Red</title>

</episode>



<episode>

<epnum>120</epnum>

<seasonnum>20</seasonnum>

<prodnum>6ABB20</prodnum>

<airdate>2002-05-14</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28196

</link>

<title>Villains</title>

</episode>



<episode>

<epnum>121</epnum>

<seasonnum>21</seasonnum>

<prodnum>6ABB21</prodnum>

<airdate>2002-05-21</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28197

</link>

<title>Two to Go (1)</title>

</episode>



<episode>

<epnum>122</epnum>

<seasonnum>22</seasonnum>

<prodnum>6ABB22</prodnum>

<airdate>2002-05-21</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28198

</link>

<title>Grave (2)</title>

</episode>

</Season>



<Season no="7">



<episode>

<epnum>123</epnum>

<seasonnum>01</seasonnum>

<prodnum>7ABB01</prodnum>

<airdate>2002-09-24</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28199

</link>

<title>Lessons</title>

</episode>



<episode>

<epnum>124</epnum>

<seasonnum>02</seasonnum>

<prodnum>7ABB02</prodnum>

<airdate>2002-10-01</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28200

</link>

<title>Beneath You</title>

</episode>



<episode>

<epnum>125</epnum>

<seasonnum>03</seasonnum>

<prodnum>7ABB03</prodnum>

<airdate>2002-10-08</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28201

</link>

<title>Same Time, Same Place</title>

</episode>



<episode>

<epnum>126</epnum>

<seasonnum>04</seasonnum>

<prodnum>7ABB04</prodnum>

<airdate>2002-10-15</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28202

</link>

<title>Help</title>

</episode>



<episode>

<epnum>127</epnum>

<seasonnum>05</seasonnum>

<prodnum>7ABB05</prodnum>

<airdate>2002-10-22</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28203

</link>

<title>Selfless</title>

</episode>



<episode>

<epnum>128</epnum>

<seasonnum>06</seasonnum>

<prodnum>7ABB06</prodnum>

<airdate>2002-11-05</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28204

</link>

<title>Him</title>

</episode>



<episode>

<epnum>129</epnum>

<seasonnum>07</seasonnum>

<prodnum>7ABB07</prodnum>

<airdate>2002-11-12</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28205

</link>

<title>Conversations with Dead People</title>

</episode>



<episode>

<epnum>130</epnum>

<seasonnum>08</seasonnum>

<prodnum>7ABB08</prodnum>

<airdate>2002-11-19</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28206

</link>

<title>Sleeper</title>

</episode>



<episode>

<epnum>131</epnum>

<seasonnum>09</seasonnum>

<prodnum>7ABB09</prodnum>

<airdate>2002-11-26</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28207

</link>

<title>Never Leave Me</title>

</episode>



<episode>

<epnum>132</epnum>

<seasonnum>10</seasonnum>

<prodnum>7ABB10</prodnum>

<airdate>2002-12-17</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28208

</link>

<title>Bring On The Night</title>

</episode>



<episode>

<epnum>133</epnum>

<seasonnum>11</seasonnum>

<prodnum>7ABB11</prodnum>

<airdate>2003-01-07</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28209

</link>

<title>Showtime</title>

</episode>



<episode>

<epnum>134</epnum>

<seasonnum>12</seasonnum>

<prodnum>7ABB12</prodnum>

<airdate>2003-01-21</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28210

</link>

<title>Potential</title>

</episode>



<episode>

<epnum>135</epnum>

<seasonnum>13</seasonnum>

<prodnum>7ABB13</prodnum>

<airdate>2003-02-04</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28211

</link>

<title>The Killer In Me</title>

</episode>



<episode>

<epnum>136</epnum>

<seasonnum>14</seasonnum>

<prodnum>7ABB14</prodnum>

<airdate>2003-02-11</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28212

</link>

<title>First Date</title>

</episode>



<episode>

<epnum>137</epnum>

<seasonnum>15</seasonnum>

<prodnum>7ABB15</prodnum>

<airdate>2003-02-18</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28213

</link>

<title>Get It Done</title>

</episode>



<episode>

<epnum>138</epnum>

<seasonnum>16</seasonnum>

<prodnum>7ABB16</prodnum>

<airdate>2003-02-25</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28214

</link>

<title>Storyteller</title>

</episode>



<episode>

<epnum>139</epnum>

<seasonnum>17</seasonnum>

<prodnum>7ABB17</prodnum>

<airdate>2003-03-25</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28215

</link>

<title>Lies My Parents Told Me</title>

</episode>



<episode>

<epnum>140</epnum>

<seasonnum>18</seasonnum>

<prodnum>7ABB18</prodnum>

<airdate>2003-04-15</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28216

</link>

<title>Dirty Girls</title>

</episode>



<episode>

<epnum>141</epnum>

<seasonnum>19</seasonnum>

<prodnum>7ABB19</prodnum>

<airdate>2003-04-29</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28217

</link>

<title>Empty Places</title>

</episode>



<episode>

<epnum>142</epnum>

<seasonnum>20</seasonnum>

<prodnum>7ABB20</prodnum>

<airdate>2003-05-06</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28218

</link>

<title>Touched</title>

</episode>



<episode>

<epnum>143</epnum>

<seasonnum>21</seasonnum>

<prodnum>7ABB21</prodnum>

<airdate>2003-05-13</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28219

</link>

<title>End of Days</title>

</episode>



<episode>

<epnum>144</epnum>

<seasonnum>22</seasonnum>

<prodnum>7ABB22</prodnum>

<airdate>2003-05-20</airdate>



<link>

http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/28220

</link>

<title>Chosen</title>

</episode>

</Season>

</Episodelist>

</Show>

Open in new window

0
Comment
Question by:billy_howard
13 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 24123783
I'm going to guess that all those unprintable characters are end-of-line characters or otherwise not needed in the XML or data base.  Would I be on firm ground?  Thanks, ~Ray
0
 
LVL 1

Author Comment

by:billy_howard
ID: 24123814
Indeed you would.

To help the actual url is:        http://www.tvrage.com/feeds/episode_list.php?sid=2930

Many Thanks
Billy
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 24123816
Cool.  It may be possible to load the XML directly with SimpleXML_Load_File().
0
 
LVL 1

Author Comment

by:billy_howard
ID: 24123832
Can you give me an example?

Billy
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 24123836
Working on that right now.  
0
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24123841
w3schools.com has some great tutorials you can use.  You might start with this one:
http://w3schools.com/php/php_xml_dom.asp
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 24123843
One note... There is an invalid character in the input - an ampersand - that should be stated as &amp;
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 24123928
Install this and run it.   Look over the code and the output.  I'll bet you can see how using the XML and OOP constructs makes it easier to parse out the data you want to put into the MySQL queries.

best regards, ~Ray
<?php // RAY_temp_bh_3.php

error_reporting(E_ALL);

echo "<pre>\n";
 
 

// THE LOCATION OF THE XML

$xml = "http://www.tvrage.com/feeds/episode_list.php?sid=2930";
 

// LOAD THE OBJECT AND TEST FOR SUCCESS

$obj = SimpleXML_Load_File($xml);

if (!$obj)

{

   die("UNUSABLE XML IN $xml");

}
 
 

// LOOK AT THE OBJECT

// var_dump($obj);
 
 
 

// FIND A FEW PARTS OF THE OBJECT

var_dump($obj->name);

var_dump($obj->totalseasons);
 
 
 

// CHECK OUT THE SEASONS - PRINT THE NUMBERS

foreach ($obj->Episodelist->Season as $my_season)

{

   print_r($my_season["no"]);

}
 
 
 

// FIND ONE OF THE SEASONS - PRINT SOME INFORMATION

foreach ($obj->Episodelist->Season as $my_season)

{

// NOTE THE OPTIONAL USE OF (string) TO RECAST THE OBJECT COMPONENT TO A STRING

   if ( (string)$my_season["no"] == "3")

   {

      foreach ($my_season->episode as $thing)

      {

         print_r($thing);

      }

   }

}
 
 
 

// FIND ONE OF THE SEASONS - ISOLATE SOME INFORMATION

foreach ($obj->Episodelist->Season as $my_season)

{

// NOTE THE USE OF (string) TO RECAST THE OBJECT COMPONENT TO A STRING

   if ($my_season["no"] == "3")

   {

      foreach ($my_season->episode as $thing)

      {

         echo "\n $thing->epnum $thing->prodnum $thing->title";

      }

   }

}

Open in new window

0
 
LVL 1

Author Comment

by:billy_howard
ID: 24124069
thats fantastic!

How can i get the actual season also? So I need to know which season the episode was in?

Many Thanks
Billy
0
 
LVL 4

Expert Comment

by:phpmonkey
ID: 24124153
In this case when foreaching ($my_season->episode as $thing) (if you don't use the if, otherwise only s3 will be shown obviously)
use $my_season["no"] for the season number
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 24124233
Hi, Billy.  I think the way that XML is hierarchical leaves you with a little bit of work to get the season number along with the episode.  I'll post a new sample in a moment.  Best, ~Ray
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 24124241
This will pick out season 3 and season 5, and shows how to get the season number and how to associate it with some of the other data in that season.

A "feature" of Simple_XML is that when you have an item between tags like <X>value of X</X> you can address it with OOP techniques like $thing->X but when you have an attribute like the season number you have to access it via array notation.

Cheers, ~Ray
<?php // RAY_temp_bh_4.php

error_reporting(E_ALL);

echo "<pre>\n";
 
 

// THE LOCATION OF THE XML

$xml = "http://www.tvrage.com/feeds/episode_list.php?sid=2930";
 

// LOAD THE OBJECT AND TEST FOR SUCCESS

$obj = SimpleXML_Load_File($xml);

if (!$obj)

{

   die("UNUSABLE XML IN $xml");

}
 
 

// LOOK AT THE OBJECT

// var_dump($obj);
 
 

// FIND TWO OF THE SEASONS - ISOLATE SOME INFORMATION

foreach ($obj->Episodelist->Season as $my_season)

{

// NOTE THE USE OF (string) TO RECAST THE OBJECT COMPONENT TO A STRING

   $season_number = (string)$my_season["no"];

   if (($season_number == "3") || ($season_number == "5"))

   {

      foreach ($my_season->episode as $thing)

      {

         echo "\n SEASON=$season_number $thing->epnum $thing->prodnum $thing->title";

      }

   }

}

Open in new window

0
 
LVL 1

Author Closing Comment

by:billy_howard
ID: 31569234
Many thanks all for your replies and help!

Billy
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now