title: Call to a member function attributes() on a non-object on line 7
body: <p>okay Guys, i have searched the answer of this problem everywhere but had no luck in solving the problem. 
  i created an xml document named questions.xml. A sample of codes is 
  i.e </p>
  
  <pre><code>&lt;Quiz&gt;
      &lt;topic text="Preparation for Exam"&gt;
          &lt;subtopic text="Science"&gt;
              &lt;question text="What is the largest planet in our solar system?"&gt; 
              &lt;answer num = "A" Text="Jupiter" correct="1"&gt;&lt;/answer&gt; 
              &lt;answer num = "B" Text="Venus" correct="0"&gt;&lt;/answer&gt; 
              &lt;answer num = "C" Text="Saturn" correct="0"&gt;&lt;/answer&gt; 
              &lt;answer num = "D" Text="Mars" correct="0"&gt;&lt;/answer&gt; 
              &lt;/question&gt;
  
              &lt;question text="What is the smallest planet?" &gt; 
              &lt;answer num = "A" Text="Pluto" correct="1"&gt;&lt;/answer&gt; 
              &lt;answer num = "B" Text="Venus" correct="0"&gt;&lt;/answer&gt; 
              &lt;answer num = "C" Text="Saturn" correct="0"&gt;&lt;/answer&gt; 
              &lt;answer num = "D" Text="Mars" correct="0"&gt;&lt;/answer&gt; 
              &lt;/question&gt;
                  &lt;/subtopic&gt;
           &lt;/topic&gt;
  &lt;/Quiz&gt; 
  </code></pre>
  
  <p>then i made a form data which shows different question numbers and i have to select one question. i used radio buttons for selection and then defined a submit button named as "question". 
  So when the user selects and submits any question then the radio button values either 0,1,2,3 etc is passed to another php page via POST method. 
  Now in this new php page i have to show the desired question in the text fieldarea. 
  the problem is i always get this stupid error "Call to a member function attributes() on a non-object on line 6". 
  My codes are </p>
  
  <pre><code>&lt;?php
      $condition= $_POST['question'];
      $xml = simplexml_load_file("questions.xml");
      echo $condition;
      if ($condition=="0"){
          $question= $xml-&gt; topic -&gt; subtopic-&gt; question[$condition] -&gt;  attributes()-&gt; text."&lt;br&gt;";
          echo "&lt;form action='' method='post'&gt; 
          &lt;label for='question'&gt; Question&lt;/label&gt;
          &lt;textarea name='question' id='1' cols='45' rows='5'&gt;".$question."&lt;/textarea&gt;
          &lt;P&gt;&lt;INPUT TYPE=SUBMIT VALUE='submit'&gt; &lt;/form&gt;";
  
          }
   ?&gt;
  </code></pre>
  
  <p>Now there is no syntax error,  and the program is displaying echo $condition , but its not displaying the question is always displays "Call to a member function attributes() on a non-object on line 6". I am really pissed ..kindly help me. </p>