Testing for optional node - Delphi XE
Posted
by
Seti Net
on Stack Overflow
See other posts from Stack Overflow
or by Seti Net
Published on 2012-06-15T22:34:23Z
Indexed on
2012/06/16
3:16 UTC
Read the original article
Hit count: 136
What is the proper way to test for the existance of an optional node? A snipped of my XML is:
<Antenna >
<Mount Model="text" Manufacture="text">
<BirdBathMount/>
</Mount>
</Antenna>
But it could also be:
<Antenna >
<Mount Model="text" Manufacture="text">
<AzEl/>
</Mount>
</Antenna>
The child of Antenna could either be BirdBath or AzEl but not both...
In Delphi XE I have tried:
if (MountNode.ChildNodes.Nodes['AzEl'] <> unassigned then //Does not work
if (MountNode.ChildNodes['BirdBathMount'].NodeValue <> null) then // Does not work
if (MountNode.BirdBathMount.NodeValue <> null) then // Does not work
I use XMLSpy to create the schema and the example XML and they parse correctly. I use Delphi XE to create the bindings and it works on most other combinations fine.
This must have a simple answer that I have just overlooked - but what? Thanks...... Jim
© Stack Overflow or respective owner