SimpleXML ile xml / atom belgeye erişim namespace element / nitelik

1 Cevap php

I may have a simple question, I need to know how to get to nested namespace attributes/elements like below

<gf:marketValue>
    <gd:money amount='150990.0' currencyCode='USD'/>
  </gf:marketValue>

bu google-api dan

Also, I am now not sure wich one I should use the url .../portfolio or portfolio/1/positions to get the stockquotes

Yani, bu konuda yanlış olabilir. (Yukarıdaki xml portföyünden vardır)

$response= simplexml_load_string($response);
foreach($response->entry as $entry)
{
$ns_gf = $entry->children('http://schemas.google.com/finance/2007');

teşekkürler zarf içinde, Richard

1 Cevap

$response= simplexml_load_string($response);

$entry_data = $response ->  xpath("//positionData");

foreach($entry_data as $data)
{
echo $data["shares"] ." <br />";

Ya da, tüm veri ve yukarıda sembolü echo hangi, bu ile gidebiliriz:

$entries = $response -> xpath("//entry");

foreach($entries as $entry) {
    echo $entry->symbol['symbol']."<br />";
    foreach($entry -> positionData -> attributes() as $att_name => $att_value) {
        echo $att_name. " = ". $att_value."</br>";
    }
}