title: Capturing text elements as variables
body: <p>I am trying to capture the first instance of particular elements from an object. I have an object $doc and would like to get the values of the following. </p>
  
  <p>id, url, alias, description and label i.e. specifically:</p>
  
  <ul>
  <li>variable1 - Q95,</li>
  <li>variable2 - //www.wikidata.org/wiki/Q95,</li>
  <li>variable3 - Google.Inc,</li>
  <li>varialbe4 - American multinational Internet and technology corporation,</li>
  <li>variable5 - Google</li>
  </ul>
  
  <p>I've made some progress getting the $jsonArr string however I'm not sure this is the best way to go, and if so I'm not sure how to progress anyway. 
  Please advise as to the best way to get these. Please see my code below:</p>
  
  <pre><code>&lt;HTML&gt;
  &lt;body&gt;
  &lt;form method="post"&gt;
  Search: &lt;input type="text" name="q" value="Google"/&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt;
  
  &lt;?php
  if (isset($_POST['q'])) {
  $search = $_POST['q']; 
  $errors = libxml_use_internal_errors(true);    
  $doc = new DOMDocument();     
  $doc-&gt;loadHTMLFile("https://www.wikidata.org/w/api.php?
  action=wbsearchentities&amp;search=$search&amp;format=json&amp;language=en");    
  libxml_clear_errors();
  libxml_use_internal_errors($errors); 
  
  var_dump($doc);
  echo "&lt;p&gt;";
  $jsonArr = $doc-&gt;documentElement-&gt;nodeValue;
  
  $jsonArr = (string)$jsonArr;
  echo $jsonArr; 
  
  }
  ?&gt;
  &lt;/body&gt;
  &lt;/HTML&gt;
  </code></pre>