Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,

I am very struggle this problem, please see two file in <completed> tag

i want output,completed value=0 condition OK, otherwise Treatment Aborted...

please kindly help me..

XML file 1
XML
<start></start>
<?xml version='1.0'>
<pit>
<vol>100</vol>
<hct>1.0</hct>
<joule>8.82</joule>
<jouleend>0.00</jouleend>
<complete>0</complete>
<runt ime>6.42</runt ime>
<pauset ime>0.00</pauset ime>
<nrpause>00</nrpause>
<temparature<27.5</temperature>
</pit>


XML file 2
XML
<start></start>
<?xml version='1.0'>
<pit>
<vol>100</vol>
<hct>1.0</hct>
<joule>8.82</joule>
<jouleend>0.00</jouleend>
<complete></complete>
<runt ime>6.42</runt ime>
<pauset ime>0.00</pauset ime>
<nrpause>00</nrpause>
<temparature<27.5</temperature>
</pit>





C#
case "complete":
             if (reader.Read())
                 {
                   if (reader.Value==null)
                    {
                     ProcedureCompletedTextBox.Text = "Treatment Aborted";
                     csvData.Append("Treatment Aborted" + ";");
                     }
                     else
                     {
                     ProcedureCompletedTextBox.Text = "OK";
                     csvData.Append("OK" + ";");
                     }
                 }


Thanks in Advance
Posted
Comments
ZurdoDev 24-Jul-14 10:35am    
All you have to do is debug. This should be easy to track down.
Om Prakash Pant 24-Jul-14 10:35am    
value will not be null. I think u can check for IsEmpty
Sergey Alexandrovich Kryukov 24-Jul-14 12:55pm    
It is very likely to be the reason; more exactly, please see my answer, where I credited your suggestion.
—SA
gggustafson 24-Jul-14 12:54pm    
Your XML file is ill-formed. Remove the <start></start> tags. XML files should start with something like

<xml version="1.0" encoding="utf-16">
Sergey Alexandrovich Kryukov 24-Jul-14 12:56pm    
Good point. In other words, it's not XML, would not parse.
The major reason is: XML has only one root element.
—SA

1 solution

Try to check if (string.IsNullOrEmpty(reader.Value)) or, if it is certainly known to be non-null, if (reader.Value != string.Empty).

Credit to Om Prakash Pant for suggestion to check for null.

—SA
 
Share this answer
 
Comments
chellapandi160 25-Jul-14 4:11am    
Yes, i got it perfect output, thank you so much for you....
Sergey Alexandrovich Kryukov 25-Jul-14 9:03am    
My pleasure.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900