title: PHP: get data from XML string
body: <p>I have a simple problem getting data from an eBay API string. I want to format numbers to 2 digits 8.0 > 8.00</p>
  
  <p>This works fine</p>
  
  <pre><code>echo $price;  // output: 8.0
  </code></pre>
  
  <p>But...</p>
  
  <pre><code>echo number_format($price, 2);  // output:   (nothing)
  </code></pre>
  
  <p>A var_dump tells me why...</p>
  
  <pre><code>var_dump($price);  
  // output: object(SimpleXMLElement)#19 (2) { ["@attributes"]=&gt; array(1) { ["currencyId"]=&gt; string(3) "USD" } [0]=&gt; string(3) "8.0" } 
  </code></pre>
  
  <p>How do I get the 8.0 into a 8.00 (I know I can use REGEX but it feels like not the proper way)</p>
  
  <p>And while we are here, how I can get the 'USD' ?</p>
  
  <p>PS: the API call used is findCompletedItems - and strangely to me, the XML response has no visible USD at all.</p>