tags:

views:

22

answers:

2

I am using simplexml to parse xml and I can get single node but not all nodes i want

example

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

only gives me the first col of the first row, i tried

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

and got nothing back

any idea what I might be doing wrong ?

  <?xml version="1.0" encoding="UTF-8"?>
  <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"&gt;
    <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>
A: 
Sean Ochoa
ahh yes that was me playing around but with the wildcard but I took it out and still nada
mcgrailm
+1  A: 

You can try with the following XPath expression which ignores the namespace:

//*[local-name() = 'COL']

This expression selects all nodes with name 'COL' no matter in what namespace the node is in.

0xA3
this seems to give me all col items regardless to what row they are in is there some way I can loop through the rows then the col
mcgrailm