XML,我有:
<?xml version="1.0" encoding="windows-1252" ?>
- <Tables>
- <Table name="I_BOOKING">
- <Row action="UPDATE" success="Y">
<Field name="AUTOBOOK">888800</Field>
<Field name="TOUROP">01</Field>
<Field name="REFERENCE">GSDFFD</Field>
<Field name="NBPAX">2</Field>
<Field name="NBINF">1</Field>
</Row>
</Table>
- <Table name="I_EXCDATERESA">
- <Row action="UPDATE" success="Y">
<Field name="EXCURS">KNO</Field>
<Field name="DATE">2012-04-12</Field>
<Field name="BOOKNR">125445</Field>
<Field name="NAME">TEST 12/4</Field>
<Field name="PICKUPTIME">00:00:00</Field>
</Row>
- <Row action="UPDATE" success="Y">
<Field name="EXCURS">KNO</Field>
<Field name="DATE">2012-04-13</Field>
<Field name="BOOKNR">14574575</Field>
<Field name="NAME">TEST 13/4</Field>
<Field name="PICKUPTIME">00:00:00</Field>
</Row>
</Table>
</Tables>
当我处理 tableI_EXCDATERESA
时,我需要获取 Field 的值BOOKNR
,所以125445
或者14574575
在这个例子中,根据我正在处理的行并将其加载$autobook
:
...
$simplexml = simplexml_import_dom($dom);
foreach ($simplexml->Table as $value)
{
$tableName = $value->attributes()->name;
foreach ($value->Row as $value)
{
if ($tableName == 'I_EXCDATERESA')
{
if ($value->Field->attributes()->name == 'BOOKNR')
{
$autoBook = $value->Field;
这不起作用,$autobook
未加载,因为它不在第一个“字段”上,而是在第三个