Groups | Blog | Home
all groups > dotnet xml > january 2007 >

dotnet xml : Hwo to handle empty fields in XML


Bill Nguyen
1/18/2007 9:23:35 AM
The following XML has an empty <UserDefinedTag /> (first record)
My VB.NET app got stuck here because I don't know how to handle it. It works
fine with a vlid user defined tag (next record)

<UserDefinedTag>40320121</UserDefinedTag>

Your help is greatly apprecited!!

Bill





- <JACOData>
- <Inventorys>
- <Inventory Type="Physical">
<Product>Dyed Diesel</Product>
<TankNumber>15008230383-1</TankNumber>
<UserDefinedTag />
<DateTime>1/14/2007 1:00:49 PM</DateTime>
<Volume>308.122</Volume>
<Ullage>2674.88</Ullage>
<Height>12</Height>
<WaterHeight>3.4</WaterHeight>
<DaystoEmpty>1</DaystoEmpty>
</Inventory>

- <Inventory Type="Physical">
<Product>Clear Diesel</Product>
<TankNumber>15008230411-1</TankNumber>
<UserDefinedTag>40320121</UserDefinedTag>
<DateTime>1/14/2007 12:00:49 PM</DateTime>
<Volume>308.122</Volume>
<Ullage>5805.88</Ullage>
<Height>12</Height>
<WaterHeight>-9.44</WaterHeight>
<DaystoEmpty>0</DaystoEmpty>
</Inventory>
- </Inventory>
</Inventorys>
</JACOData>


Robert May
1/18/2007 1:26:57 PM
Bill,

Check to see if the UserDefinedTag has children. If so, you know there's a
value supplied, if not, it doesn't have one.

Robert

[quoted text, click to view]

Bill Nguyen
1/18/2007 5:08:00 PM
Robert;

This element doesn't have children.
All I need to know is how to detect an empty element so the application
(VB.NET) can react properly.

Thanks!

Bill

[quoted text, click to view]

Keith Patrick
1/19/2007 11:11:54 AM
String.IsNullOrEmpty(myNode.InnerText)



Bill Nguyen
1/19/2007 1:19:35 PM
Thanks Keith!

This works well.

Bill
[quoted text, click to view]

AddThis Social Bookmark Button