cdouglas
2008-02-07 22:03:43 UTC
Hello,
I am having an issue trying to remove a data object using xpath and
unset and its not working a I expect.
Example:
<record>
<tns:logicalPort id="lp24" parentId="mpg5" portId="24">
<tns:extendedData dataType="name" instance="1">LP 24</
tns:extendedData>
<tns:logicalPortLocation>LP 24</tns:logicalPortLocation>
</tns:logicalPort>
<tns:logicalPort id="lp25" parentId="mpg6" portId="25">
<tns:logicalPortLocation>Lp11222</tns:logicalPortLocation>
</tns:logicalPort>
</record>
I want to remove the entire object for <tns:logicalPort id="lp25"
parentId="mpg6" portId="25"> based on the portId.
So remove this:
<tns:logicalPort id="lp24" parentId="mpg5" portId="24">
<tns:extendedData dataType="name" instance="1">LP 24</
tns:extendedData>
<tns:logicalPortLocation>LP 24</tns:logicalPortLocation>
</tns:logicalPort>
The XML is loaded in to the object $record
If I execute unset($record["logicalPort[portId=24]"]) , nothing
happens.
But If I execute unset($record["logicalPort[portId=24]"]->parentId) ,
then the parentID value is removed, so I am not completely off base.
How can I remove the entire section?
Thanks
Chris
I am having an issue trying to remove a data object using xpath and
unset and its not working a I expect.
Example:
<record>
<tns:logicalPort id="lp24" parentId="mpg5" portId="24">
<tns:extendedData dataType="name" instance="1">LP 24</
tns:extendedData>
<tns:logicalPortLocation>LP 24</tns:logicalPortLocation>
</tns:logicalPort>
<tns:logicalPort id="lp25" parentId="mpg6" portId="25">
<tns:logicalPortLocation>Lp11222</tns:logicalPortLocation>
</tns:logicalPort>
</record>
I want to remove the entire object for <tns:logicalPort id="lp25"
parentId="mpg6" portId="25"> based on the portId.
So remove this:
<tns:logicalPort id="lp24" parentId="mpg5" portId="24">
<tns:extendedData dataType="name" instance="1">LP 24</
tns:extendedData>
<tns:logicalPortLocation>LP 24</tns:logicalPortLocation>
</tns:logicalPort>
The XML is loaded in to the object $record
If I execute unset($record["logicalPort[portId=24]"]) , nothing
happens.
But If I execute unset($record["logicalPort[portId=24]"]->parentId) ,
then the parentID value is removed, so I am not completely off base.
How can I remove the entire section?
Thanks
Chris