XML:
<Routes>
<Route type="source" >
<Table>
<Tablename>incoming</Tablename>
<Fields>
<Fieldsname ref="dest">truegoto</Fieldsname>
</Fields>
</Table>
</Route>
</Routes>
PHP:
$doc = new SimpleXMLElement('routingConfig.xml', null, true);
$foo = $doc->xpath('/Routes/Route[@type="source"]/Table/Tablename[incoming]/following-sibling::Fields/Fieldsname[@ref="dest"]');
print_r($foo);
试图truegoto
通过知道的方式得到<Tablename>incoming</Tablename>
。我当前的代码只返回一个空数组:/