title: Why can't I select the desired node using this PHP Xpath expression?
body: <p>Using PHP, SimpleXML and the xpath() function, I want to select a child node, starting from a certain point. 
  Can you please help me? I know in this specific case I could use an expression starting with "//", but I want to learn the right way of selecting a child node.
  Thanks.</p>
  
  <p><strong>First try</strong> -- fails with <em>Undefined offset: 0</em> error</p>
  
  <pre><code>$navXmlObject = simplexml_load_file("main_navigation.xml");
  $tmpObject = $navXmlObject-&gt;website-&gt;xpath('title[@lang="fr"]'); 
  echo($tmpObject[0]["label"]);
  </code></pre>
  
  <p><strong>Second try, adding a slash</strong> -- also fails with the same error</p>
  
  <pre><code>$tmpObject = $navXmlObject-&gt;website-&gt;xpath('/title[@lang="fr"]'); 
  </code></pre>
  
  <p>XML file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root&gt;
      &lt;website id="MainWeb"&gt;
          &lt;title lang="fr" label="Mon site Web" /&gt;        
          &lt;title lang="en" label="My web site" /&gt;     
          &lt;menuNodes&gt;
  
              &lt;menuNode id="Home"&gt;
                  &lt;menuNodeData lang="fr" label="Accueil" url="/fr/accueil/" /&gt;
                  &lt;menuNodeData lang="en" label="Home" url="/en/home/" /&gt;
              &lt;/menuNode&gt;
  
              &lt;menuNode id="Prod"&gt;
  
                  &lt;menuNodeData lang="fr" label="Produits" url="/fr/produits/" /&gt;
                  &lt;menuNodeData lang="en" label="Products" url="/en/products/" /&gt;
  
                  &lt;menuNode id="Shoe"&gt;
                      &lt;menuNodeData lang="fr" label="Chaussures" url="/fr/produits/chaussures/" /&gt;
                      &lt;menuNodeData lang="en" label="Shoes" url="/en/products/shoes/" /&gt;
                  &lt;/menuNode&gt;
  
              &lt;/menuNode&gt;
  
              &lt;menuNode id="Biog"&gt;
                  &lt;menuNodeData lang="fr" label="Biographie du fondateur" url="/fr/biographie/" /&gt;
                  &lt;menuNodeData lang="en" label="Biography of founder" url="/en/biography/" /&gt;
              &lt;/menuNode&gt;
  
          &lt;/menuNodes&gt;
      &lt;/website&gt;
  &lt;/root&gt;
  </code></pre>