title: Retrieve xsl:variable in xml using PHP
body: <p>Note.xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="./xsl/avsdk.xsl"?&gt;
  
  &lt;Table CreatedOn="Tue Nov 17 22:30:53 PST 2015" Name="Hello" Version="3.6.10294.2" TimeStamp="1447828253"&gt;
  .....
  .....
  &lt;/Table&gt;
  </code></pre>
  
  <p>Previoulsy we have used the above xml file and used the below PHP command to retrieve the value for Table tag Name and Version, and processed the Table data using Xml object to convert it to other format.</p>
  
  <p>PHP:</p>
  
  <pre><code>$xml = simplexml_load_file("note.xml")
  $table_attrs = $xml-&gt;attributes();
  if( 0 === strpos( $table_attrs["Name"], "Hello" ) )
  {
  .....
  }
  else if( 0 === strpos( $table_attrs["Name"], "Hai" ) )
  {
  .....
  }
  </code></pre>
  
  <p>Now the XML file format changed like below. So i have changed the command like below(i.e $xml->Table[0]->attributes()) to take the Table tag Name and version, and store the entire table content as a XML object to convert it to other format. when i tried to run the below PHP command, it throws the error "Fatal error: Call to a member function attributes() on null". Please let me know the command to take Table Name and version, and how to store the entire Table content as a xml object </p>
  
  <p>Note.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="no"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="#sc_stylesheet"?&gt;
  &lt;!DOCTYPE supportchart [&lt;!ATTLIST xsl:stylesheet id ID #REQUIRED&gt;]&gt;
  
  &lt;xsl:stylesheet id="sc_stylesheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
      &lt;xsl:output method="html" omit-xml-declaration="yes"/&gt;
      &lt;xsl:variable name="support_chart"&gt;
          &lt;supportchart&gt;
              &lt;Table CreatedOn="Wed Feb 03 15:52:32 2016" Name="Hello" Version="4.2.326.0" Timestamp="1454543552.61"&gt;
              .....
              .....
              &lt;/Table&gt;
          &lt;/supportchart&gt;
      &lt;/xsl:variable&gt; 
      &lt;xsl:template match="Table"&gt;
      ....
      ....
      &lt;xsl:template match="xsl:template"&gt; &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>$xml = simplexml_load_file("note.xml")
  $table_attrs = $xml-&gt;Table[0]-&gt;attributes();
  if( 0 === strpos( $table_attrs["Name"], "Hello" ) )
  {
  .....
  }
  else if( 0 === strpos( $table_attrs["Name"], "Hai" ) )
  {
  .....
  }
  </code></pre>