php从具有相等值的xml文件中检索

问题描述 投票:0回答:1

我正在尝试从xlsx文件中仅恢复某些值。对我来说造成问题的文件是worksheets / sheet1.xml,其结构为...

<sheetData>
    <row (attribbutes)>
        <c (attributes)>
            <v>value</v>
        </c>    
        .....
        <c (attributes)>
            <v>value</v>
        </c>
    </row>
    ......      
    <row (attribbutes)>
        <c (attributes)>
            <v>value</v>
        </c>    
        .....
        <c (attributes)>
            <v>value</v>
        </c>
    </row>
</sheetData>

我的问题是,我感兴趣的价值观不同,但它们可以相同。例如:我需要一个月中的某天的数字(例如16),但是该数字也是允许我查找同事姓名的指针,而当我读取该行的属性时,我找不到任何东西我预计。以下是我使用的代码

$sheet1 = 'sheet1.xml';
$getrow = file_get_contents($sheet1);
$xmlrow   = simplexml_load_string($getrow);
foreach ($xmlrow->sheetData->row as $row_0) {
    foreach ($row_0->c as $c_0) 
    {
        foreach ($c_0->v as $v) 
        {
            if ($v[0] == $preserve) /****** This changes when search for number day of the month (if $v == $day)
            {    
                $attr_0 = $c_0->attributes();
                $row = $attr_0['r'];
                break 3;
            }
        }
    }
}

如何在正确的行中获得正确的值?

php xml
1个回答
0
投票
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.