php kullanarak XML dosyasında kök düğümün ilk çocuk düğüm seçin

0 Cevap php

Ben XML yeniyim ve şimdiye kadar php bu kullanarak bir XML kök düğümü elde başardı ...

function xmlRootNode($xmlfile){
    $xml = simplexml_load_string(file_get_contents($xmlfile));
    $xml = $xml->getName();
    echo $xml;
}

And what I now want to do is use that root node to find out the name of its child node. For example, a file with the below would output 'food' as the root using the above function. How would I now use that to return its childs name 'fruit'?

<food>
  <fruit>
    <type>apples</type>
  </fruit>
</food>

Sonuçta ne yapmaya çalışıyorum ben o zaman kaç sayar başka bir fonksiyonu kullanabilirsiniz böylece kök düğümün alt düğümü adını bulmak. Googling ve farklı fikirler etrafında karıştırmasını ama bir yere kadar herhangi bir fikir takdir basit bir süreç eksik düşünüyorum olmuştur.

0 Cevap