1
我有這個XML輸出。我在PHP中將它提供給simpleXML。我試圖找回所有的看臺,地塊和樹木。出於某種原因,我只是在第一個展位而不是第二個展位獲得這些地塊。樹木也是一樣,我只是把樹倒在第一架。我使用的代碼在XML下面發佈。我嘗試了許多不同的方式來擊中這些部分,但沒有運氣。在PHP中使用simpleXML缺少項目
<Tracts>
<tract>
<tract>tract1</tract>
<county>Glynn</county>
<state>GA</state>
<name>Garrett</name>
<owner>Bob</owner>
<date>Nov 6, 2011</date>
<stands>
<Stand>
<stand>1</stand>
<age>12</age>
<thinned>true</thinned>
<thinYear>2007</thinYear>
<species>PL Lob</species>
<cruiser>me</cruiser>
<hPlotSize>50th Acre</hPlotSize>
<pPlotSize>50th Acre</pPlotSize>
<treeType>None</treeType>
<fixedOrPrism>5</fixedOrPrism>
<plots>
<Plot>
<plotNum>5</plotNum>
<pPMStems>12</pPMStems>
<hPMStems>12</hPMStems>
<pPMHt>12</pPMHt>
<hPMHt>12</hPMHt>
<pMStems>12</pMStems>
<hMStems>12</hMStems>
<pMHt>0</pMHt>
<hMHt>12</hMHt>
<pHtCrown>0</pHtCrown>
<trees>
<Tree>
<treeNum>3</treeNum>
<DBH>18</DBH>
<species>LOB</species>
<type>CROP</type>
<merch>12</merch>
<htToCrown>9</htToCrown>
<merchLogs>1.0</merchLogs>
<defects>
<string>CRON</string>
<string>SCRAPE</string>
</defects>
</Tree>
<Tree>
<treeNum>3</treeNum>
<DBH>18</DBH>
<species>LOB</species>
<type>CROP</type>
<merch>12</merch>
<htToCrown>9</htToCrown>
<merchLogs>1.0</merchLogs>
<defects>
<string>CRON</string>
<string>SCRAPE</string>
</defects>
</Tree>
<Tree>
<treeNum>3</treeNum>
<DBH>18</DBH>
<species>LOB</species>
<type>CROP</type>
<merch>12</merch>
<htToCrown>9</htToCrown>
<merchLogs>1.0</merchLogs>
<defects>
<string>CRON</string>
<string>SCRAPE</string>
</defects>
</Tree>
</trees>
</Plot>
<Plot>
<plotNum>9</plotNum>
<pPMStems>3</pPMStems>
<hPMStems>3</hPMStems>
<pPMHt>3</pPMHt>
<hPMHt>3</hPMHt>
<pMStems>3</pMStems>
<hMStems>3</hMStems>
<pMHt>0</pMHt>
<hMHt>3</hMHt>
<pHtCrown>0</pHtCrown>
<trees />
</Plot>
</plots>
</Stand>
<Stand>
<stand>2</stand>
<age>20</age>
<thinned>false</thinned>
<thinYear>0</thinYear>
<species>PL Lob</species>
<cruiser>me</cruiser>
<hPlotSize>50th Acre</hPlotSize>
<pPlotSize>10th Acre</pPlotSize>
<treeType>Fixed</treeType>
<fixedOrPrism>100%</fixedOrPrism>
<plots>
<Plot>
<plotNum>2</plotNum>
<pPMStems>12</pPMStems>
<hPMStems>20</hPMStems>
<pPMHt>32</pPMHt>
<hPMHt>16</hPMHt>
<pMStems>21</pMStems>
<hMStems>7</hMStems>
<pMHt>0</pMHt>
<hMHt>13</hMHt>
<pHtCrown>0</pHtCrown>
<trees>
<Tree>
<treeNum>1</treeNum>
<DBH>10</DBH>
<species>LOB</species>
<type>CROP</type>
<merch>12</merch>
<htToCrown>16</htToCrown>
<merchLogs>4.5</merchLogs>
<defects>
<string>CRON</string>
<string>OTHER</string>
</defects>
</Tree>
</trees>
</Plot>
</plots>
</Stand>
</stands>
</tract>
</Tracts>
foreach($xml->tract->stands->Stand->plots->Plot as $plot)
{
echo $plot->plotNum;
}
echo '<br><br>';
foreach ($xml->tract->stands->Stand->plots->Plot->trees->Tree as $tree)
{
echo $tree->treeNum;
}