tüm unsurları almak için xpath

0 Cevap php

Ben xml ayrıştırmak için SimpleXML kullanıyorum ve ben tek bir düğümü alabilirsiniz ama tüm düğümler i istiyorum

örnek

    $xmlObject = simplexml_load_file($xml_file); // load the xml file
        $cols = $xmlObject->RESULTSET->ROW->COL;
    foreach ( $cols as $COL) {
        echo $COL->DATA;
    }

bana sadece ilk satırın ilk col verir, ben denedim

    $xmlObject = simplexml_load_file($xml_file); // load the xml file
    $cols = $xmlObject->xpath('*//COL');
    foreach ( $cols as $COL) {
        echo $COL->DATA;
    }

ve hiçbir şey döndüm

Ben yanlış yapıyor olabilir bir fikrin?

  <?xml version="1.0" encoding="UTF-8"?>
  <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
    <RESULTSET FOUND="445">
        <ROW MODID="45" RECORDID="1">
            <COL>
                <DATA>Integrating Ethanol</DATA>
            </COL>
            <COL>
                <DATA/>
            </COL>
            <COL>
                <DATA>train track and gas pump</DATA>
            </COL>
            <COL>
                <DATA/>
            </COL>
            <COL>
                <DATA/>
            </COL>
            <COL>
                <DATA>1.jpg</DATA>
            </COL>
            <COL>
                <DATA/>
            </COL>
        </ROW>
        <ROW MODID="29" RECORDID="3">
            <COL>
                <DATA>Keeping in Balance</DATA>
            </COL>
            <COL>
                <DATA>21</DATA>
            </COL>
            <COL>
                <DATA>book cover of Sweet Invisible Body</DATA>
            </COL>
            <COL>
                <DATA/>
            </COL>
        </ROW>
    </RESULTSET>
  </FMPXMLRESULT>

0 Cevap